<html>
<!-- =====================================================================

  File:      Generated file for Adventure Works Cycles Storefront Sample
  Summary:   Self-documentation for application
  Date:	     June 16, 2003

=====================================================================

  This file is part of the Microsoft SQL Server Code Samples.
  Copyright (C) 2003 Microsoft Corporation.  All rights reserved.

This source code is intended only as a supplement to Microsoft
Development Tools and/or on-line documentation.  See these other
materials for detailed information regarding Microsoft code samples.

THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
PARTICULAR PURPOSE.

======================================================= -->
<head>
  <link rel=stylesheet href=style.css>
</head>
<body>
<div class=SourcePanel style="font-size:12">
<pre style="background-color:white">
<span style="color: #0000FF"><strong>using</strong></span> <span style="color: #2040a0">System</span><span style="color: #4444FF">;</span>
<span style="color: #0000FF"><strong>using</strong></span> <span style="color: #2040a0">System</span>.<span style="color: #2040a0">Configuration</span><span style="color: #4444FF">;</span>
<span style="color: #0000FF"><strong>using</strong></span> <span style="color: #2040a0">System</span>.<span style="color: #2040a0">Data</span><span style="color: #4444FF">;</span>
<span style="color: #0000FF"><strong>using</strong></span> <span style="color: #2040a0">System</span>.<span style="color: #2040a0">Data</span>.<span style="color: #2040a0">SqlClient</span><span style="color: #4444FF">;</span>
<span style="color: #0000FF"><strong>using</strong></span> <span style="color: #2040a0">System</span>.<span style="color: #2040a0">Security</span>.<span style="color: #2040a0">Cryptography</span><span style="color: #4444FF">;</span>
<span style="color: #0000FF"><strong>using</strong></span> <span style="color: #2040a0">System</span>.<span style="color: #2040a0">Web</span><span style="color: #4444FF">;</span>
<span style="color: #0000FF"><strong>using</strong></span> <span style="color: #2040a0">System</span>.<span style="color: #2040a0">Web</span>.<span style="color: #2040a0">Security</span><span style="color: #4444FF">;</span>
<span style="color: #0000FF"><strong>using</strong></span> <span style="color: #2040a0">System</span>.<span style="color: #2040a0">Diagnostics</span><span style="color: #4444FF">;</span>
<span style="color: #0000FF"><strong>using</strong></span> <span style="color: #2040a0">System</span>.<span style="color: #2040a0">Globalization</span><span style="color: #4444FF">;</span>

<span style="color: #008000">/*=====================================================================

  File:      CustomersDB.cs for Adventure Works Cycles Storefront Sample
  Summary:   Middle tier component for manipulating customer information.
  Date:	     June 16, 2003

---------------------------------------------------------------------

  This file is part of the Microsoft SQL Server Code Samples.
  Copyright (C) Microsoft Corporation.  All rights reserved.

This source code is intended only as a supplement to Microsoft
Development Tools and/or on-line documentation.  See these other
materials for detailed information regarding Microsoft code samples.

THIS CODE AND INFORMATION ARE PROVIDED &quot;AS IS&quot; WITHOUT WARRANTY OF ANY
KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
PARTICULAR PURPOSE.

======================================================= */</span>


<span style="color: #0000FF"><strong>namespace</strong></span> <span style="color: #2040a0">Microsoft</span>.<span style="color: #2040a0">Samples</span>.<span style="color: #2040a0">SqlServer</span> 
<span style="color: #4444FF"><strong>{</strong></span>

	

    <span style="color: #008000">//*******************************************************</span>
    <span style="color: #008000">//</span>
    <span style="color: #008000">// CustomerDetails Class</span>
    <span style="color: #008000">//</span>
    <span style="color: #008000">// A simple data class that encapsulates details about</span>
    <span style="color: #008000">// a particular customer inside the AdventureWorks</span>
    <span style="color: #008000">// database.</span>
	<span style="color: #008000">//</span>
    <span style="color: #008000">//</span>
    <span style="color: #008000">//*******************************************************</span>

    <span style="color: #0000FF"><strong>public</strong></span> <span style="color: #0000FF"><strong>class</strong></span> <span style="color: #2040a0">CustomerDetails</span> <span style="color: #4444FF"><strong>{</strong></span>
		<span style="color: #0000FF"><strong>private</strong></span> <span style="color: #2040a0">String</span> <span style="color: #2040a0">customerID</span><span style="color: #4444FF">;</span>
		<span style="color: #0000FF"><strong>private</strong></span> <span style="color: #2040a0">String</span> <span style="color: #2040a0">firstName</span><span style="color: #4444FF">;</span>
		<span style="color: #0000FF"><strong>private</strong></span> <span style="color: #2040a0">String</span> <span style="color: #2040a0">lastName</span><span style="color: #4444FF">;</span>
		<span style="color: #0000FF"><strong>private</strong></span> <span style="color: #2040a0">String</span> <span style="color: #2040a0">email</span><span style="color: #4444FF">;</span>
		<span style="color: #0000FF"><strong>private</strong></span> <span style="color: #2040a0">String</span> <span style="color: #2040a0">passwordHash</span><span style="color: #4444FF">;</span>
		<span style="color: #0000FF"><strong>private</strong></span> <span style="color: #2040a0">String</span> <span style="color: #2040a0">passwordSalt</span><span style="color: #4444FF">;</span>
		<span style="color: #0000FF"><strong>private</strong></span> <span style="color: #0000FF"><strong>int</strong></span> <span style="color: #2040a0">emailPromotion</span><span style="color: #4444FF">;</span>

		<span style="color: #008000">// The fields above are exposed publically as properties</span>
		<span style="color: #008000">// There is nothing fancy going on here, it is just better </span>
		<span style="color: #008000">// practice to not expose public fields.  This helps avoid binary </span>
		<span style="color: #008000">// incompatabilities if the public fields were to have to</span>
		<span style="color: #008000">// be changed to properties later.</span>
		
		<span style="color: #0000FF"><strong>public</strong></span> <span style="color: #2040a0">String</span> <span style="color: #2040a0">CustomerID</span>
		<span style="color: #4444FF"><strong>{</strong></span>
			<span style="color: #2040a0">get</span>
			<span style="color: #4444FF"><strong>{</strong></span>
				<span style="color: #0000FF"><strong>return</strong></span> <span style="color: #2040a0">customerID</span><span style="color: #4444FF">;</span>
			<span style="color: #4444FF"><strong>}</strong></span>
			<span style="color: #2040a0">set</span>
			<span style="color: #4444FF"><strong>{</strong></span>
				<span style="color: #2040a0">customerID</span> <span style="color: #4444FF">=</span> <span style="color: #2040a0">value</span><span style="color: #4444FF">;</span>
			<span style="color: #4444FF"><strong>}</strong></span>
		<span style="color: #4444FF"><strong>}</strong></span>
		
		<span style="color: #0000FF"><strong>public</strong></span> <span style="color: #2040a0">String</span> <span style="color: #2040a0">FirstName</span>
		<span style="color: #4444FF"><strong>{</strong></span>
			<span style="color: #2040a0">get</span>
			<span style="color: #4444FF"><strong>{</strong></span>
				<span style="color: #0000FF"><strong>return</strong></span> <span style="color: #2040a0">firstName</span><span style="color: #4444FF">;</span>
			<span style="color: #4444FF"><strong>}</strong></span>
			<span style="color: #2040a0">set</span>
			<span style="color: #4444FF"><strong>{</strong></span>
				<span style="color: #2040a0">firstName</span> <span style="color: #4444FF">=</span> <span style="color: #2040a0">value</span><span style="color: #4444FF">;</span>
			<span style="color: #4444FF"><strong>}</strong></span>
		<span style="color: #4444FF"><strong>}</strong></span>
		<span style="color: #0000FF"><strong>public</strong></span> <span style="color: #2040a0">String</span> <span style="color: #2040a0">LastName</span>
		<span style="color: #4444FF"><strong>{</strong></span>
			<span style="color: #2040a0">get</span>
			<span style="color: #4444FF"><strong>{</strong></span>
				<span style="color: #0000FF"><strong>return</strong></span> <span style="color: #2040a0">lastName</span><span style="color: #4444FF">;</span>
			<span style="color: #4444FF"><strong>}</strong></span>
			<span style="color: #2040a0">set</span>
			<span style="color: #4444FF"><strong>{</strong></span>
				<span style="color: #2040a0">lastName</span> <span style="color: #4444FF">=</span> <span style="color: #2040a0">value</span><span style="color: #4444FF">;</span>
			<span style="color: #4444FF"><strong>}</strong></span>
		<span style="color: #4444FF"><strong>}</strong></span>
        <span style="color: #0000FF"><strong>public</strong></span> <span style="color: #2040a0">String</span> <span style="color: #2040a0">Email</span>
		<span style="color: #4444FF"><strong>{</strong></span>
			<span style="color: #2040a0">get</span>
			<span style="color: #4444FF"><strong>{</strong></span>
				<span style="color: #0000FF"><strong>return</strong></span> <span style="color: #2040a0">email</span><span style="color: #4444FF">;</span>
			<span style="color: #4444FF"><strong>}</strong></span>
			<span style="color: #2040a0">set</span>
			<span style="color: #4444FF"><strong>{</strong></span>
				<span style="color: #2040a0">email</span> <span style="color: #4444FF">=</span> <span style="color: #2040a0">value</span><span style="color: #4444FF">;</span>
			<span style="color: #4444FF"><strong>}</strong></span>
		<span style="color: #4444FF"><strong>}</strong></span>
        <span style="color: #0000FF"><strong>public</strong></span> <span style="color: #2040a0">String</span> <span style="color: #2040a0">PasswordHash</span>
		<span style="color: #4444FF"><strong>{</strong></span>
			<span style="color: #2040a0">get</span>
			<span style="color: #4444FF"><strong>{</strong></span>
				<span style="color: #0000FF"><strong>return</strong></span> <span style="color: #2040a0">passwordHash</span><span style="color: #4444FF">;</span>
			<span style="color: #4444FF"><strong>}</strong></span>
			<span style="color: #2040a0">set</span>
			<span style="color: #4444FF"><strong>{</strong></span>
				<span style="color: #2040a0">passwordHash</span> <span style="color: #4444FF">=</span> <span style="color: #2040a0">value</span><span style="color: #4444FF">;</span>
			<span style="color: #4444FF"><strong>}</strong></span>
		<span style="color: #4444FF"><strong>}</strong></span>
		<span style="color: #0000FF"><strong>public</strong></span> <span style="color: #2040a0">String</span> <span style="color: #2040a0">PasswordSalt</span>
		<span style="color: #4444FF"><strong>{</strong></span>
			<span style="color: #2040a0">get</span>
			<span style="color: #4444FF"><strong>{</strong></span>
				<span style="color: #0000FF"><strong>return</strong></span> <span style="color: #2040a0">passwordSalt</span><span style="color: #4444FF">;</span>
			<span style="color: #4444FF"><strong>}</strong></span>
			<span style="color: #2040a0">set</span>
			<span style="color: #4444FF"><strong>{</strong></span>
				<span style="color: #2040a0">passwordSalt</span> <span style="color: #4444FF">=</span> <span style="color: #2040a0">value</span><span style="color: #4444FF">;</span>
			<span style="color: #4444FF"><strong>}</strong></span>
		<span style="color: #4444FF"><strong>}</strong></span>

		<span style="color: #0000FF"><strong>public</strong></span> <span style="color: #0000FF"><strong>int</strong></span> <span style="color: #2040a0">EmailPromotion</span>
		<span style="color: #4444FF"><strong>{</strong></span>
			<span style="color: #2040a0">get</span>
			<span style="color: #4444FF"><strong>{</strong></span>
				<span style="color: #0000FF"><strong>return</strong></span> <span style="color: #2040a0">emailPromotion</span><span style="color: #4444FF">;</span>
			<span style="color: #4444FF"><strong>}</strong></span>
			<span style="color: #2040a0">set</span>
			<span style="color: #4444FF"><strong>{</strong></span>
				<span style="color: #2040a0">emailPromotion</span> <span style="color: #4444FF">=</span> <span style="color: #2040a0">value</span><span style="color: #4444FF">;</span>
			<span style="color: #4444FF"><strong>}</strong></span>
		<span style="color: #4444FF"><strong>}</strong></span>

		<span style="color: #0000FF"><strong>public</strong></span> <span style="color: #2040a0">CustomerDetails</span><span style="color: #4444FF">(</span><span style="color: #2040a0">String</span> <span style="color: #2040a0">customerID</span>, <span style="color: #2040a0">String</span> <span style="color: #2040a0">firstName</span>,
			<span style="color: #2040a0">String</span> <span style="color: #2040a0">lastName</span>, <span style="color: #2040a0">String</span> <span style="color: #2040a0">email</span>, <span style="color: #2040a0">String</span> <span style="color: #2040a0">passwordHash</span>,
			<span style="color: #2040a0">String</span> <span style="color: #2040a0">passwordSalt</span>, <span style="color: #0000FF"><strong>int</strong></span> <span style="color: #2040a0">emailPromotion</span><span style="color: #4444FF">)</span>
		<span style="color: #4444FF"><strong>{</strong></span>
			<span style="color: #0000FF"><strong>this</strong></span>.<span style="color: #2040a0">customerID</span> <span style="color: #4444FF">=</span> <span style="color: #2040a0">customerID</span><span style="color: #4444FF">;</span>
			<span style="color: #0000FF"><strong>this</strong></span>.<span style="color: #2040a0">firstName</span> <span style="color: #4444FF">=</span> <span style="color: #2040a0">firstName</span><span style="color: #4444FF">;</span>
			<span style="color: #0000FF"><strong>this</strong></span>.<span style="color: #2040a0">lastName</span> <span style="color: #4444FF">=</span> <span style="color: #2040a0">lastName</span><span style="color: #4444FF">;</span>
			<span style="color: #0000FF"><strong>this</strong></span>.<span style="color: #2040a0">email</span> <span style="color: #4444FF">=</span> <span style="color: #2040a0">email</span><span style="color: #4444FF">;</span>
			<span style="color: #0000FF"><strong>this</strong></span>.<span style="color: #2040a0">passwordHash</span> <span style="color: #4444FF">=</span> <span style="color: #2040a0">passwordHash</span><span style="color: #4444FF">;</span>
			<span style="color: #0000FF"><strong>this</strong></span>.<span style="color: #2040a0">passwordSalt</span> <span style="color: #4444FF">=</span> <span style="color: #2040a0">passwordSalt</span><span style="color: #4444FF">;</span>
			<span style="color: #0000FF"><strong>this</strong></span>.<span style="color: #2040a0">emailPromotion</span> <span style="color: #4444FF">=</span> <span style="color: #2040a0">emailPromotion</span><span style="color: #4444FF">;</span>
		<span style="color: #4444FF"><strong>}</strong></span>
    <span style="color: #4444FF"><strong>}</strong></span>

	<span style="color: #0000FF"><strong>public</strong></span> <span style="color: #0000FF"><strong>class</strong></span> <span style="color: #2040a0">CustomerAddress</span>
	<span style="color: #4444FF"><strong>{</strong></span>
		<span style="color: #0000FF"><strong>private</strong></span> <span style="color: #0000FF"><strong>int</strong></span> <span style="color: #2040a0">addressID</span> <span style="color: #4444FF">=</span> <span style="color: #4444FF">-</span><span style="color: #FF0000">1</span><span style="color: #4444FF">;</span>
		<span style="color: #0000FF"><strong>private</strong></span> <span style="color: #2040a0">String</span> <span style="color: #2040a0">line1</span> <span style="color: #4444FF">=</span> <span style="color: #444444">&quot;&quot;</span><span style="color: #4444FF">;</span>
		<span style="color: #0000FF"><strong>private</strong></span> <span style="color: #2040a0">String</span> <span style="color: #2040a0">line2</span> <span style="color: #4444FF">=</span> <span style="color: #444444">&quot;&quot;</span><span style="color: #4444FF">;</span>
		<span style="color: #0000FF"><strong>private</strong></span> <span style="color: #2040a0">String</span> <span style="color: #2040a0">city</span> <span style="color: #4444FF">=</span> <span style="color: #444444">&quot;&quot;</span><span style="color: #4444FF">;</span>
		<span style="color: #0000FF"><strong>private</strong></span> <span style="color: #0000FF"><strong>int</strong></span> <span style="color: #2040a0">stateProvinceID</span> <span style="color: #4444FF">=</span> <span style="color: #4444FF">-</span><span style="color: #FF0000">1</span><span style="color: #4444FF">;</span>
		<span style="color: #0000FF"><strong>private</strong></span> <span style="color: #2040a0">String</span> <span style="color: #2040a0">stateProvinceName</span> <span style="color: #4444FF">=</span> <span style="color: #444444">&quot;&quot;</span><span style="color: #4444FF">;</span>
		<span style="color: #0000FF"><strong>private</strong></span> <span style="color: #2040a0">String</span> <span style="color: #2040a0">postalCode</span> <span style="color: #4444FF">=</span> <span style="color: #444444">&quot;&quot;</span><span style="color: #4444FF">;</span>

		<span style="color: #0000FF"><strong>public</strong></span> <span style="color: #2040a0">CustomerAddress</span><span style="color: #4444FF">(</span><span style="color: #4444FF">)</span>
		<span style="color: #4444FF"><strong>{</strong></span>
		<span style="color: #4444FF"><strong>}</strong></span>

		<span style="color: #0000FF"><strong>public</strong></span> <span style="color: #2040a0">CustomerAddress</span><span style="color: #4444FF">(</span><span style="color: #0000FF"><strong>int</strong></span> <span style="color: #2040a0">addressID</span>, <span style="color: #2040a0">String</span> <span style="color: #2040a0">line1</span>, <span style="color: #2040a0">String</span> <span style="color: #2040a0">line2</span>,
							   <span style="color: #2040a0">String</span> <span style="color: #2040a0">city</span>, <span style="color: #0000FF"><strong>int</strong></span> <span style="color: #2040a0">stateProvinceID</span>, <span style="color: #2040a0">String</span> <span style="color: #2040a0">stateProvinceName</span>,
							   <span style="color: #2040a0">String</span> <span style="color: #2040a0">postalCode</span><span style="color: #4444FF">)</span>
		<span style="color: #4444FF"><strong>{</strong></span>
			<span style="color: #0000FF"><strong>this</strong></span>.<span style="color: #2040a0">addressID</span> <span style="color: #4444FF">=</span> <span style="color: #2040a0">addressID</span><span style="color: #4444FF">;</span>
			<span style="color: #0000FF"><strong>this</strong></span>.<span style="color: #2040a0">line1</span> <span style="color: #4444FF">=</span> <span style="color: #2040a0">line1</span><span style="color: #4444FF">;</span>
			<span style="color: #0000FF"><strong>this</strong></span>.<span style="color: #2040a0">line2</span> <span style="color: #4444FF">=</span> <span style="color: #2040a0">line2</span><span style="color: #4444FF">;</span>
			<span style="color: #0000FF"><strong>this</strong></span>.<span style="color: #2040a0">city</span> <span style="color: #4444FF">=</span> <span style="color: #2040a0">city</span><span style="color: #4444FF">;</span>
			<span style="color: #0000FF"><strong>this</strong></span>.<span style="color: #2040a0">stateProvinceID</span> <span style="color: #4444FF">=</span> <span style="color: #2040a0">stateProvinceID</span><span style="color: #4444FF">;</span>
			<span style="color: #0000FF"><strong>this</strong></span>.<span style="color: #2040a0">stateProvinceName</span> <span style="color: #4444FF">=</span> <span style="color: #2040a0">stateProvinceName</span><span style="color: #4444FF">;</span>
			<span style="color: #0000FF"><strong>this</strong></span>.<span style="color: #2040a0">postalCode</span> <span style="color: #4444FF">=</span> <span style="color: #2040a0">postalCode</span><span style="color: #4444FF">;</span>
		<span style="color: #4444FF"><strong>}</strong></span>

		<span style="color: #008000">// The fields above are exposed publically as properties</span>
		<span style="color: #008000">// There is nothing fancy going on here, it is just better </span>
		<span style="color: #008000">// practice to not expose public fields.  This helps avoid binary </span>
		<span style="color: #008000">// incompatabilities if the public fields were to have to</span>
		<span style="color: #008000">// be changed to properties later.</span>

		<span style="color: #0000FF"><strong>public</strong></span> <span style="color: #0000FF"><strong>int</strong></span> <span style="color: #2040a0">AddressID</span>
		<span style="color: #4444FF"><strong>{</strong></span>
			<span style="color: #2040a0">get</span>
			<span style="color: #4444FF"><strong>{</strong></span>
				<span style="color: #0000FF"><strong>return</strong></span> <span style="color: #2040a0">addressID</span><span style="color: #4444FF">;</span>
			<span style="color: #4444FF"><strong>}</strong></span>
			<span style="color: #2040a0">set</span>
			<span style="color: #4444FF"><strong>{</strong></span>
				<span style="color: #2040a0">addressID</span> <span style="color: #4444FF">=</span> <span style="color: #2040a0">value</span><span style="color: #4444FF">;</span>
			<span style="color: #4444FF"><strong>}</strong></span>
		<span style="color: #4444FF"><strong>}</strong></span>
			
		<span style="color: #0000FF"><strong>public</strong></span> <span style="color: #2040a0">String</span> <span style="color: #2040a0">Line1</span>
		<span style="color: #4444FF"><strong>{</strong></span>
			<span style="color: #2040a0">get</span>
			<span style="color: #4444FF"><strong>{</strong></span>
				<span style="color: #0000FF"><strong>return</strong></span> <span style="color: #2040a0">line1</span><span style="color: #4444FF">;</span>
			<span style="color: #4444FF"><strong>}</strong></span>
			<span style="color: #2040a0">set</span>
			<span style="color: #4444FF"><strong>{</strong></span>
				<span style="color: #2040a0">line1</span> <span style="color: #4444FF">=</span> <span style="color: #2040a0">value</span><span style="color: #4444FF">;</span>
			<span style="color: #4444FF"><strong>}</strong></span>
		<span style="color: #4444FF"><strong>}</strong></span>

		<span style="color: #0000FF"><strong>public</strong></span> <span style="color: #2040a0">String</span> <span style="color: #2040a0">Line2</span>
		<span style="color: #4444FF"><strong>{</strong></span>
			<span style="color: #2040a0">get</span>
			<span style="color: #4444FF"><strong>{</strong></span>
				<span style="color: #0000FF"><strong>return</strong></span> <span style="color: #2040a0">line2</span><span style="color: #4444FF">;</span>
			<span style="color: #4444FF"><strong>}</strong></span>
			<span style="color: #2040a0">set</span>
			<span style="color: #4444FF"><strong>{</strong></span>
				<span style="color: #2040a0">line2</span> <span style="color: #4444FF">=</span> <span style="color: #2040a0">value</span><span style="color: #4444FF">;</span>
			<span style="color: #4444FF"><strong>}</strong></span>
		<span style="color: #4444FF"><strong>}</strong></span>

		<span style="color: #0000FF"><strong>public</strong></span> <span style="color: #2040a0">String</span> <span style="color: #2040a0">City</span>
		<span style="color: #4444FF"><strong>{</strong></span>
			<span style="color: #2040a0">get</span>
			<span style="color: #4444FF"><strong>{</strong></span>
				<span style="color: #0000FF"><strong>return</strong></span> <span style="color: #2040a0">city</span><span style="color: #4444FF">;</span>
			<span style="color: #4444FF"><strong>}</strong></span>
			<span style="color: #2040a0">set</span>
			<span style="color: #4444FF"><strong>{</strong></span>
				<span style="color: #2040a0">city</span> <span style="color: #4444FF">=</span> <span style="color: #2040a0">value</span><span style="color: #4444FF">;</span>
			<span style="color: #4444FF"><strong>}</strong></span>
		<span style="color: #4444FF"><strong>}</strong></span>

		<span style="color: #0000FF"><strong>public</strong></span> <span style="color: #0000FF"><strong>int</strong></span> <span style="color: #2040a0">StateProvinceID</span>
		<span style="color: #4444FF"><strong>{</strong></span>
			<span style="color: #2040a0">get</span>
			<span style="color: #4444FF"><strong>{</strong></span>
				<span style="color: #0000FF"><strong>return</strong></span> <span style="color: #2040a0">stateProvinceID</span><span style="color: #4444FF">;</span>
			<span style="color: #4444FF"><strong>}</strong></span>
			<span style="color: #2040a0">set</span>
			<span style="color: #4444FF"><strong>{</strong></span>
				<span style="color: #2040a0">stateProvinceID</span> <span style="color: #4444FF">=</span> <span style="color: #2040a0">value</span><span style="color: #4444FF">;</span>
			<span style="color: #4444FF"><strong>}</strong></span>
		<span style="color: #4444FF"><strong>}</strong></span>

		<span style="color: #0000FF"><strong>public</strong></span> <span style="color: #2040a0">String</span> <span style="color: #2040a0">StateProvinceName</span>
		<span style="color: #4444FF"><strong>{</strong></span>
			<span style="color: #2040a0">get</span>
			<span style="color: #4444FF"><strong>{</strong></span>
				<span style="color: #0000FF"><strong>return</strong></span> <span style="color: #2040a0">stateProvinceName</span><span style="color: #4444FF">;</span>
			<span style="color: #4444FF"><strong>}</strong></span>
			<span style="color: #2040a0">set</span>
			<span style="color: #4444FF"><strong>{</strong></span>
				<span style="color: #2040a0">StateProvinceName</span> <span style="color: #4444FF">=</span> <span style="color: #2040a0">value</span><span style="color: #4444FF">;</span>
			<span style="color: #4444FF"><strong>}</strong></span>
		<span style="color: #4444FF"><strong>}</strong></span>

		<span style="color: #0000FF"><strong>public</strong></span> <span style="color: #2040a0">String</span> <span style="color: #2040a0">PostalCode</span>
		<span style="color: #4444FF"><strong>{</strong></span>
			<span style="color: #2040a0">get</span>
			<span style="color: #4444FF"><strong>{</strong></span>
				<span style="color: #0000FF"><strong>return</strong></span> <span style="color: #2040a0">postalCode</span><span style="color: #4444FF">;</span>
			<span style="color: #4444FF"><strong>}</strong></span>
			<span style="color: #2040a0">set</span>
			<span style="color: #4444FF"><strong>{</strong></span>
				<span style="color: #2040a0">postalCode</span> <span style="color: #4444FF">=</span> <span style="color: #2040a0">value</span><span style="color: #4444FF">;</span>
			<span style="color: #4444FF"><strong>}</strong></span>
		<span style="color: #4444FF"><strong>}</strong></span>

		<span style="color: #0000FF"><strong>public</strong></span> <span style="color: #0000FF"><strong>void</strong></span> <span style="color: #2040a0">FillAddress</span> <span style="color: #4444FF">(</span><span style="color: #2040a0">DataTable</span> <span style="color: #2040a0">dt</span><span style="color: #4444FF">)</span>
		<span style="color: #4444FF"><strong>{</strong></span>
			<span style="color: #0000FF"><strong>if</strong></span> <span style="color: #4444FF">(</span><span style="color: #2040a0">dt</span>.<span style="color: #2040a0">Rows</span>.<span style="color: #2040a0">Count</span> <span style="color: #4444FF">&gt;</span> <span style="color: #FF0000">0</span><span style="color: #4444FF">)</span>
			<span style="color: #4444FF"><strong>{</strong></span>
				<span style="color: #2040a0">DataRow</span> <span style="color: #2040a0">dr</span> <span style="color: #4444FF">=</span> <span style="color: #2040a0">dt</span>.<span style="color: #2040a0">Rows</span><span style="color: #4444FF">[</span><span style="color: #FF0000">0</span><span style="color: #4444FF">]</span><span style="color: #4444FF">;</span>
				<span style="color: #2040a0">addressID</span> <span style="color: #4444FF">=</span> <span style="color: #4444FF">(</span><span style="color: #0000FF"><strong>int</strong></span><span style="color: #4444FF">)</span><span style="color: #2040a0">dr</span><span style="color: #4444FF">[</span><span style="color: #444444">&quot;AddressID&quot;</span><span style="color: #4444FF">]</span><span style="color: #4444FF">;</span>
				<span style="color: #2040a0">line1</span> <span style="color: #4444FF">=</span> <span style="color: #4444FF">(</span><span style="color: #2040a0">String</span><span style="color: #4444FF">)</span><span style="color: #2040a0">dr</span><span style="color: #4444FF">[</span><span style="color: #444444">&quot;AddressLine1&quot;</span><span style="color: #4444FF">]</span><span style="color: #4444FF">;</span>
				<span style="color: #2040a0">line2</span> <span style="color: #4444FF">=</span> <span style="color: #4444FF">(</span><span style="color: #2040a0">String</span><span style="color: #4444FF">)</span><span style="color: #2040a0">dr</span><span style="color: #4444FF">[</span><span style="color: #444444">&quot;AddressLine2&quot;</span><span style="color: #4444FF">]</span><span style="color: #4444FF">;</span>
				<span style="color: #2040a0">city</span> <span style="color: #4444FF">=</span> <span style="color: #4444FF">(</span><span style="color: #2040a0">String</span><span style="color: #4444FF">)</span><span style="color: #2040a0">dr</span><span style="color: #4444FF">[</span><span style="color: #444444">&quot;City&quot;</span><span style="color: #4444FF">]</span><span style="color: #4444FF">;</span>
				<span style="color: #2040a0">stateProvinceID</span> <span style="color: #4444FF">=</span> <span style="color: #4444FF">(</span><span style="color: #0000FF"><strong>int</strong></span><span style="color: #4444FF">)</span><span style="color: #2040a0">dr</span><span style="color: #4444FF">[</span><span style="color: #444444">&quot;StateProvinceID&quot;</span><span style="color: #4444FF">]</span><span style="color: #4444FF">;</span>
				<span style="color: #2040a0">stateProvinceName</span> <span style="color: #4444FF">=</span> <span style="color: #4444FF">(</span><span style="color: #2040a0">String</span><span style="color: #4444FF">)</span><span style="color: #2040a0">dr</span><span style="color: #4444FF">[</span><span style="color: #444444">&quot;StateProvinceName&quot;</span><span style="color: #4444FF">]</span><span style="color: #4444FF">;</span>
				<span style="color: #2040a0">postalCode</span> <span style="color: #4444FF">=</span> <span style="color: #4444FF">(</span><span style="color: #2040a0">String</span><span style="color: #4444FF">)</span><span style="color: #2040a0">dr</span><span style="color: #4444FF">[</span><span style="color: #444444">&quot;postalCode&quot;</span><span style="color: #4444FF">]</span><span style="color: #4444FF">;</span>
			<span style="color: #4444FF"><strong>}</strong></span>
		<span style="color: #4444FF"><strong>}</strong></span>
	<span style="color: #4444FF"><strong>}</strong></span>

	<span style="color: #0000FF"><strong>public</strong></span> <span style="color: #0000FF"><strong>class</strong></span> <span style="color: #2040a0">CustomerAddresses</span>
	<span style="color: #4444FF"><strong>{</strong></span>
		<span style="color: #0000FF"><strong>private</strong></span> <span style="color: #2040a0">CustomerAddress</span> <span style="color: #2040a0">billingAddress</span><span style="color: #4444FF">;</span>
		<span style="color: #0000FF"><strong>private</strong></span> <span style="color: #2040a0">CustomerAddress</span> <span style="color: #2040a0">shippingAddress</span><span style="color: #4444FF">;</span>

		<span style="color: #0000FF"><strong>public</strong></span> <span style="color: #2040a0">CustomerAddresses</span><span style="color: #4444FF">(</span><span style="color: #2040a0">CustomerAddress</span> <span style="color: #2040a0">billingAddress</span>, <span style="color: #2040a0">CustomerAddress</span> <span style="color: #2040a0">shippingAddress</span><span style="color: #4444FF">)</span>
		<span style="color: #4444FF"><strong>{</strong></span>
			<span style="color: #0000FF"><strong>this</strong></span>.<span style="color: #2040a0">billingAddress</span> <span style="color: #4444FF">=</span> <span style="color: #2040a0">billingAddress</span><span style="color: #4444FF">;</span>
			<span style="color: #0000FF"><strong>this</strong></span>.<span style="color: #2040a0">shippingAddress</span> <span style="color: #4444FF">=</span> <span style="color: #2040a0">shippingAddress</span><span style="color: #4444FF">;</span>
		<span style="color: #4444FF"><strong>}</strong></span>

		<span style="color: #0000FF"><strong>public</strong></span> <span style="color: #2040a0">CustomerAddress</span> <span style="color: #2040a0">BillingAddress</span>
		<span style="color: #4444FF"><strong>{</strong></span>
			<span style="color: #2040a0">get</span>
			<span style="color: #4444FF"><strong>{</strong></span>
				<span style="color: #0000FF"><strong>return</strong></span> <span style="color: #2040a0">billingAddress</span><span style="color: #4444FF">;</span>
			<span style="color: #4444FF"><strong>}</strong></span>
			<span style="color: #2040a0">set</span>
			<span style="color: #4444FF"><strong>{</strong></span>
				<span style="color: #2040a0">billingAddress</span> <span style="color: #4444FF">=</span> <span style="color: #2040a0">value</span><span style="color: #4444FF">;</span>
			<span style="color: #4444FF"><strong>}</strong></span>
		<span style="color: #4444FF"><strong>}</strong></span>

		<span style="color: #0000FF"><strong>public</strong></span> <span style="color: #2040a0">CustomerAddress</span> <span style="color: #2040a0">ShippingAddress</span>
		<span style="color: #4444FF"><strong>{</strong></span>
			<span style="color: #2040a0">get</span>
			<span style="color: #4444FF"><strong>{</strong></span>
				<span style="color: #0000FF"><strong>return</strong></span> <span style="color: #2040a0">shippingAddress</span><span style="color: #4444FF">;</span>
			<span style="color: #4444FF"><strong>}</strong></span>
			<span style="color: #2040a0">set</span>
			<span style="color: #4444FF"><strong>{</strong></span>
				<span style="color: #2040a0">shippingAddress</span> <span style="color: #4444FF">=</span> <span style="color: #2040a0">value</span><span style="color: #4444FF">;</span>
			<span style="color: #4444FF"><strong>}</strong></span>
		<span style="color: #4444FF"><strong>}</strong></span>
	<span style="color: #4444FF"><strong>}</strong></span>


    <span style="color: #008000">//*******************************************************</span>
    <span style="color: #008000">//</span>
    <span style="color: #008000">// CustomersDB Class</span>
    <span style="color: #008000">//</span>
    <span style="color: #008000">// Business/Data Logic Class that encapsulates all data</span>
    <span style="color: #008000">// logic necessary to add/login/query customers within</span>
    <span style="color: #008000">// the AdventureWorks database.</span>
    <span style="color: #008000">//</span>
    <span style="color: #008000">//*******************************************************</span>

    <span style="color: #0000FF"><strong>public</strong></span> <span style="color: #0000FF"><strong>class</strong></span> <span style="color: #2040a0">CustomersDB</span> <span style="color: #4444FF"><strong>{</strong></span>

		<span style="color: #0000FF"><strong>private</strong></span> <span style="color: #0000FF"><strong>static</strong></span> <span style="color: #2040a0">string</span> <span style="color: #2040a0">CreateSalt</span><span style="color: #4444FF">(</span><span style="color: #0000FF"><strong>int</strong></span> <span style="color: #2040a0">size</span><span style="color: #4444FF">)</span>
		<span style="color: #4444FF"><strong>{</strong></span>
			<span style="color: #008000">// Generate a cryptographic random number using the cryptographic</span>
			<span style="color: #008000">// service provider</span>
			<span style="color: #2040a0">RNGCryptoServiceProvider</span> <span style="color: #2040a0">rng</span> <span style="color: #4444FF">=</span> <span style="color: #0000FF"><strong>new</strong></span> <span style="color: #2040a0">RNGCryptoServiceProvider</span><span style="color: #4444FF">(</span><span style="color: #4444FF">)</span><span style="color: #4444FF">;</span>
			<span style="color: #2040a0">byte</span><span style="color: #4444FF">[</span><span style="color: #4444FF">]</span> <span style="color: #2040a0">buff</span> <span style="color: #4444FF">=</span> <span style="color: #0000FF"><strong>new</strong></span> <span style="color: #2040a0">byte</span><span style="color: #4444FF">[</span><span style="color: #2040a0">size</span><span style="color: #4444FF">]</span><span style="color: #4444FF">;</span>
			<span style="color: #2040a0">rng</span>.<span style="color: #2040a0">GetBytes</span><span style="color: #4444FF">(</span><span style="color: #2040a0">buff</span><span style="color: #4444FF">)</span><span style="color: #4444FF">;</span>
			<span style="color: #008000">// Return a Base64 string representation of the random number</span>
			<span style="color: #0000FF"><strong>return</strong></span> <span style="color: #2040a0">Convert</span>.<span style="color: #2040a0">ToBase64String</span><span style="color: #4444FF">(</span><span style="color: #2040a0">buff</span><span style="color: #4444FF">)</span><span style="color: #4444FF">;</span>
		<span style="color: #4444FF"><strong>}</strong></span>

		<span style="color: #0000FF"><strong>public</strong></span> <span style="color: #0000FF"><strong>static</strong></span> <span style="color: #2040a0">string</span> <span style="color: #2040a0">CreatePasswordHash</span><span style="color: #4444FF">(</span><span style="color: #2040a0">string</span> <span style="color: #2040a0">pwd</span>, <span style="color: #2040a0">string</span> <span style="color: #2040a0">salt</span><span style="color: #4444FF">)</span>
		<span style="color: #4444FF"><strong>{</strong></span>
			<span style="color: #2040a0">string</span> <span style="color: #2040a0">saltAndPwd</span> <span style="color: #4444FF">=</span> <span style="color: #2040a0">String</span>.<span style="color: #2040a0">Concat</span><span style="color: #4444FF">(</span><span style="color: #2040a0">pwd</span>, <span style="color: #2040a0">salt</span><span style="color: #4444FF">)</span><span style="color: #4444FF">;</span>
			<span style="color: #2040a0">string</span> <span style="color: #2040a0">hashedPwd</span> <span style="color: #4444FF">=</span>
				<span style="color: #2040a0">FormsAuthentication</span>.<span style="color: #2040a0">HashPasswordForStoringInConfigFile</span><span style="color: #4444FF">(</span>
				<span style="color: #2040a0">saltAndPwd</span>, <span style="color: #444444">&quot;SHA1&quot;</span><span style="color: #4444FF">)</span><span style="color: #4444FF">;</span>
			<span style="color: #0000FF"><strong>return</strong></span> <span style="color: #2040a0">hashedPwd</span><span style="color: #4444FF">;</span>
		<span style="color: #4444FF"><strong>}</strong></span>

        <span style="color: #008000">//*******************************************************</span>
        <span style="color: #008000">//</span>
        <span style="color: #008000">// CustomersDB.GetCustomerDetails() Method &lt;a name=&quot;GetCustomerDetails&quot;&gt;&lt;/a&gt;</span>
        <span style="color: #008000">//</span>
        <span style="color: #008000">// The GetCustomerDetails method returns a CustomerDetails</span>
        <span style="color: #008000">// struct that contains information about a specific</span>
        <span style="color: #008000">// customer (name, email, password, etc).</span>
        <span style="color: #008000">//</span>
        <span style="color: #008000">// Other relevant sources:</span>
        <span style="color: #008000">//     + &lt;a href=&quot;usp_CustomerDetail.htm&quot; style=&quot;color:green&quot;&gt;usp_CustomerDetail Stored Procedure&lt;/a&gt;</span>
        <span style="color: #008000">//</span>
        <span style="color: #008000">//*******************************************************</span>

        <span style="color: #0000FF"><strong>public</strong></span> <span style="color: #2040a0">CustomerDetails</span> <span style="color: #2040a0">GetCustomerDetails</span><span style="color: #4444FF">(</span><span style="color: #2040a0">String</span> <span style="color: #2040a0">customerID</span><span style="color: #4444FF">)</span> 
        <span style="color: #4444FF"><strong>{</strong></span>
            <span style="color: #008000">// Create Instance of Connection and Command Object</span>
			<span style="color: #2040a0">SqlConnection</span> <span style="color: #2040a0">myConnection</span> <span style="color: #4444FF">=</span> <span style="color: #0000FF"><strong>new</strong></span> <span style="color: #2040a0">SqlConnection</span><span style="color: #4444FF">(</span>
				<span style="color: #2040a0">Properties</span>.<span style="color: #2040a0">Settings</span>.<span style="color: #2040a0">Default</span>.<span style="color: #2040a0">ConnectionString</span><span style="color: #4444FF">)</span><span style="color: #4444FF">;</span> 
            <span style="color: #2040a0">SqlCommand</span> <span style="color: #2040a0">myCommand</span> <span style="color: #4444FF">=</span> <span style="color: #0000FF"><strong>new</strong></span> <span style="color: #2040a0">SqlCommand</span><span style="color: #4444FF">(</span><span style="color: #444444">&quot;usp_CustomerDetail&quot;</span>, <span style="color: #2040a0">myConnection</span><span style="color: #4444FF">)</span><span style="color: #4444FF">;</span>

            <span style="color: #008000">// Mark the Command as a SPROC</span>
            <span style="color: #2040a0">myCommand</span>.<span style="color: #2040a0">CommandType</span> <span style="color: #4444FF">=</span> <span style="color: #2040a0">CommandType</span>.<span style="color: #2040a0">StoredProcedure</span><span style="color: #4444FF">;</span>

            <span style="color: #008000">// Add Parameters to SPROC</span>
            <span style="color: #2040a0">SqlParameter</span> <span style="color: #2040a0">parameterCustomerID</span> <span style="color: #4444FF">=</span> <span style="color: #0000FF"><strong>new</strong></span> <span style="color: #2040a0">SqlParameter</span><span style="color: #4444FF">(</span><span style="color: #444444">&quot;@CustomerID&quot;</span>, <span style="color: #2040a0">SqlDbType</span>.<span style="color: #2040a0">Int</span>, <span style="color: #FF0000">4</span><span style="color: #4444FF">)</span><span style="color: #4444FF">;</span>
            <span style="color: #2040a0">parameterCustomerID</span>.<span style="color: #2040a0">Value</span> <span style="color: #4444FF">=</span> <span style="color: #2040a0">Int32</span>.<span style="color: #2040a0">Parse</span><span style="color: #4444FF">(</span><span style="color: #2040a0">customerID</span>, <span style="color: #2040a0">CultureInfo</span>.<span style="color: #2040a0">InvariantCulture</span><span style="color: #4444FF">)</span><span style="color: #4444FF">;</span>
            <span style="color: #2040a0">myCommand</span>.<span style="color: #2040a0">Parameters</span>.<span style="color: #2040a0">Add</span><span style="color: #4444FF">(</span><span style="color: #2040a0">parameterCustomerID</span><span style="color: #4444FF">)</span><span style="color: #4444FF">;</span>

            <span style="color: #2040a0">SqlParameter</span> <span style="color: #2040a0">parameterFirstName</span> <span style="color: #4444FF">=</span> <span style="color: #0000FF"><strong>new</strong></span> <span style="color: #2040a0">SqlParameter</span><span style="color: #4444FF">(</span><span style="color: #444444">&quot;@FirstName&quot;</span>, <span style="color: #2040a0">SqlDbType</span>.<span style="color: #2040a0">NVarChar</span>, <span style="color: #FF0000">50</span><span style="color: #4444FF">)</span><span style="color: #4444FF">;</span>
            <span style="color: #2040a0">parameterFirstName</span>.<span style="color: #2040a0">Direction</span> <span style="color: #4444FF">=</span> <span style="color: #2040a0">ParameterDirection</span>.<span style="color: #2040a0">Output</span><span style="color: #4444FF">;</span>
            <span style="color: #2040a0">myCommand</span>.<span style="color: #2040a0">Parameters</span>.<span style="color: #2040a0">Add</span><span style="color: #4444FF">(</span><span style="color: #2040a0">parameterFirstName</span><span style="color: #4444FF">)</span><span style="color: #4444FF">;</span>

			<span style="color: #2040a0">SqlParameter</span> <span style="color: #2040a0">parameterLastName</span> <span style="color: #4444FF">=</span> <span style="color: #0000FF"><strong>new</strong></span> <span style="color: #2040a0">SqlParameter</span><span style="color: #4444FF">(</span><span style="color: #444444">&quot;@LastName&quot;</span>, <span style="color: #2040a0">SqlDbType</span>.<span style="color: #2040a0">NVarChar</span>, <span style="color: #FF0000">50</span><span style="color: #4444FF">)</span><span style="color: #4444FF">;</span>
			<span style="color: #2040a0">parameterLastName</span>.<span style="color: #2040a0">Direction</span> <span style="color: #4444FF">=</span> <span style="color: #2040a0">ParameterDirection</span>.<span style="color: #2040a0">Output</span><span style="color: #4444FF">;</span>
			<span style="color: #2040a0">myCommand</span>.<span style="color: #2040a0">Parameters</span>.<span style="color: #2040a0">Add</span><span style="color: #4444FF">(</span><span style="color: #2040a0">parameterLastName</span><span style="color: #4444FF">)</span><span style="color: #4444FF">;</span>

            <span style="color: #2040a0">SqlParameter</span> <span style="color: #2040a0">parameterEmail</span> <span style="color: #4444FF">=</span> <span style="color: #0000FF"><strong>new</strong></span> <span style="color: #2040a0">SqlParameter</span><span style="color: #4444FF">(</span><span style="color: #444444">&quot;@Email&quot;</span>, <span style="color: #2040a0">SqlDbType</span>.<span style="color: #2040a0">NVarChar</span>, <span style="color: #FF0000">50</span><span style="color: #4444FF">)</span><span style="color: #4444FF">;</span>
            <span style="color: #2040a0">parameterEmail</span>.<span style="color: #2040a0">Direction</span> <span style="color: #4444FF">=</span> <span style="color: #2040a0">ParameterDirection</span>.<span style="color: #2040a0">Output</span><span style="color: #4444FF">;</span>
            <span style="color: #2040a0">myCommand</span>.<span style="color: #2040a0">Parameters</span>.<span style="color: #2040a0">Add</span><span style="color: #4444FF">(</span><span style="color: #2040a0">parameterEmail</span><span style="color: #4444FF">)</span><span style="color: #4444FF">;</span>

            <span style="color: #2040a0">SqlParameter</span> <span style="color: #2040a0">parameterPasswordHash</span> <span style="color: #4444FF">=</span> <span style="color: #0000FF"><strong>new</strong></span> <span style="color: #2040a0">SqlParameter</span><span style="color: #4444FF">(</span><span style="color: #444444">&quot;@PasswordHash&quot;</span>, <span style="color: #2040a0">SqlDbType</span>.<span style="color: #2040a0">VarChar</span>, <span style="color: #FF0000">40</span><span style="color: #4444FF">)</span><span style="color: #4444FF">;</span>
            <span style="color: #2040a0">parameterPasswordHash</span>.<span style="color: #2040a0">Direction</span> <span style="color: #4444FF">=</span> <span style="color: #2040a0">ParameterDirection</span>.<span style="color: #2040a0">Output</span><span style="color: #4444FF">;</span>
            <span style="color: #2040a0">myCommand</span>.<span style="color: #2040a0">Parameters</span>.<span style="color: #2040a0">Add</span><span style="color: #4444FF">(</span><span style="color: #2040a0">parameterPasswordHash</span><span style="color: #4444FF">)</span><span style="color: #4444FF">;</span>

			<span style="color: #2040a0">SqlParameter</span> <span style="color: #2040a0">parameterPasswordSalt</span> <span style="color: #4444FF">=</span> <span style="color: #0000FF"><strong>new</strong></span> <span style="color: #2040a0">SqlParameter</span><span style="color: #4444FF">(</span><span style="color: #444444">&quot;@PasswordSalt&quot;</span>, <span style="color: #2040a0">SqlDbType</span>.<span style="color: #2040a0">VarChar</span>, <span style="color: #FF0000">10</span><span style="color: #4444FF">)</span><span style="color: #4444FF">;</span>
			<span style="color: #2040a0">parameterPasswordSalt</span>.<span style="color: #2040a0">Direction</span> <span style="color: #4444FF">=</span> <span style="color: #2040a0">ParameterDirection</span>.<span style="color: #2040a0">Output</span><span style="color: #4444FF">;</span>
			<span style="color: #2040a0">myCommand</span>.<span style="color: #2040a0">Parameters</span>.<span style="color: #2040a0">Add</span><span style="color: #4444FF">(</span><span style="color: #2040a0">parameterPasswordSalt</span><span style="color: #4444FF">)</span><span style="color: #4444FF">;</span>

			<span style="color: #2040a0">SqlParameter</span> <span style="color: #2040a0">parameterEmailPromotion</span> <span style="color: #4444FF">=</span> <span style="color: #0000FF"><strong>new</strong></span> <span style="color: #2040a0">SqlParameter</span><span style="color: #4444FF">(</span>
				<span style="color: #444444">&quot;@EmailPromotion&quot;</span>, <span style="color: #2040a0">SqlDbType</span>.<span style="color: #2040a0">Int</span><span style="color: #4444FF">)</span><span style="color: #4444FF">;</span>
			<span style="color: #2040a0">parameterEmailPromotion</span>.<span style="color: #2040a0">Direction</span> <span style="color: #4444FF">=</span> <span style="color: #2040a0">ParameterDirection</span>.<span style="color: #2040a0">Output</span><span style="color: #4444FF">;</span>
			<span style="color: #2040a0">myCommand</span>.<span style="color: #2040a0">Parameters</span>.<span style="color: #2040a0">Add</span><span style="color: #4444FF">(</span><span style="color: #2040a0">parameterEmailPromotion</span><span style="color: #4444FF">)</span><span style="color: #4444FF">;</span>

            <span style="color: #2040a0">try</span>
            <span style="color: #4444FF"><strong>{</strong></span>
                <span style="color: #2040a0">myConnection</span>.<span style="color: #2040a0">Open</span><span style="color: #4444FF">(</span><span style="color: #4444FF">)</span><span style="color: #4444FF">;</span>
                <span style="color: #2040a0">myCommand</span>.<span style="color: #2040a0">ExecuteNonQuery</span><span style="color: #4444FF">(</span><span style="color: #4444FF">)</span><span style="color: #4444FF">;</span>
            <span style="color: #4444FF"><strong>}</strong></span>
            <span style="color: #2040a0">finally</span>
            <span style="color: #4444FF"><strong>{</strong></span>
                <span style="color: #2040a0">myConnection</span>.<span style="color: #2040a0">Close</span><span style="color: #4444FF">(</span><span style="color: #4444FF">)</span><span style="color: #4444FF">;</span>
            <span style="color: #4444FF"><strong>}</strong></span>

            <span style="color: #008000">// Create CustomerDetails class and populate it.</span>
            <span style="color: #2040a0">CustomerDetails</span> <span style="color: #2040a0">myCustomerDetails</span> 
							<span style="color: #4444FF">=</span> <span style="color: #0000FF"><strong>new</strong></span> <span style="color: #2040a0">CustomerDetails</span><span style="color: #4444FF">(</span><span style="color: #2040a0">customerID</span>, <span style="color: #4444FF">(</span><span style="color: #2040a0">string</span><span style="color: #4444FF">)</span><span style="color: #2040a0">parameterFirstName</span>.<span style="color: #2040a0">Value</span>,
							<span style="color: #4444FF">(</span><span style="color: #2040a0">string</span><span style="color: #4444FF">)</span><span style="color: #2040a0">parameterLastName</span>.<span style="color: #2040a0">Value</span>, 
							<span style="color: #4444FF">(</span><span style="color: #2040a0">string</span><span style="color: #4444FF">)</span><span style="color: #2040a0">parameterEmail</span>.<span style="color: #2040a0">Value</span>, 
							<span style="color: #4444FF">(</span><span style="color: #2040a0">string</span><span style="color: #4444FF">)</span><span style="color: #2040a0">parameterPasswordHash</span>.<span style="color: #2040a0">Value</span>,
							<span style="color: #4444FF">(</span><span style="color: #2040a0">string</span><span style="color: #4444FF">)</span><span style="color: #2040a0">parameterPasswordSalt</span>.<span style="color: #2040a0">Value</span>, 
							<span style="color: #4444FF">(</span><span style="color: #2040a0">parameterEmailPromotion</span>.<span style="color: #2040a0">Value</span> <span style="color: #2040a0">is</span> <span style="color: #0000FF"><strong>int</strong></span><span style="color: #4444FF">)</span> ? <span style="color: #4444FF">(</span><span style="color: #0000FF"><strong>int</strong></span><span style="color: #4444FF">)</span><span style="color: #2040a0">parameterEmailPromotion</span>.
							<span style="color: #2040a0">Value</span> <span style="color: #4444FF">:</span> <span style="color: #FF0000">0</span><span style="color: #4444FF">)</span><span style="color: #4444FF">;</span>

  
			<span style="color: #0000FF"><strong>return</strong></span> <span style="color: #2040a0">myCustomerDetails</span><span style="color: #4444FF">;</span>
        <span style="color: #4444FF"><strong>}</strong></span>

        <span style="color: #008000">//*******************************************************</span>
        <span style="color: #008000">//</span>
        <span style="color: #008000">// CustomersDB.AddCustomer() Method &lt;a name=&quot;AddCustomer&quot;&gt;&lt;/a&gt;</span>
        <span style="color: #008000">//</span>
        <span style="color: #008000">// The AddCustomer method inserts a new customer record</span>
        <span style="color: #008000">// into the database.  A unique &quot;CustomerId&quot;</span>
        <span style="color: #008000">// key is then returned from the method.  This can be</span>
        <span style="color: #008000">// used later to place orders, track shopping carts,</span>
        <span style="color: #008000">// etc within the ecommerce system.  Exceptions should</span>
        <span style="color: #008000">// be caught by the caller.</span>
        <span style="color: #008000">// Other relevant sources:</span>
        <span style="color: #008000">//     + &lt;a href=&quot;usp_CustomerAdd.htm&quot; style=&quot;color:green&quot;&gt;usp_CustomerAdd Stored Procedure&lt;/a&gt;</span>
        <span style="color: #008000">//</span>
        <span style="color: #008000">//*******************************************************</span>

        <span style="color: #0000FF"><strong>public</strong></span> <span style="color: #2040a0">String</span> <span style="color: #2040a0">AddCustomer</span><span style="color: #4444FF">(</span><span style="color: #2040a0">string</span> <span style="color: #2040a0">firstName</span>, <span style="color: #2040a0">string</span> <span style="color: #2040a0">lastName</span>, <span style="color: #2040a0">string</span> <span style="color: #2040a0">email</span>, <span style="color: #2040a0">string</span> <span style="color: #2040a0">password</span><span style="color: #4444FF">)</span> 
        <span style="color: #4444FF"><strong>{</strong></span>
			<span style="color: #0000FF"><strong>if</strong></span> <span style="color: #4444FF">(</span><span style="color: #2040a0">GetCustomerID</span><span style="color: #4444FF">(</span><span style="color: #2040a0">email</span><span style="color: #4444FF">)</span> <span style="color: #4444FF">!</span><span style="color: #4444FF">=</span> <span style="color: #FF0000">0</span><span style="color: #4444FF">)</span> 
				<span style="color: #0000FF"><strong>throw</strong></span> <span style="color: #0000FF"><strong>new</strong></span> <span style="color: #2040a0">UserAlreadyExistsException</span><span style="color: #4444FF">(</span><span style="color: #2040a0">string</span>.<span style="color: #2040a0">Format</span><span style="color: #4444FF">(</span><span style="color: #2040a0">CultureInfo</span>.<span style="color: #2040a0">InvariantCulture</span>, <span style="color: #444444">&quot;The email address {0} is already in use&quot;</span>, 
					<span style="color: #2040a0">email</span><span style="color: #4444FF">)</span><span style="color: #4444FF">)</span><span style="color: #4444FF">;</span>

			<span style="color: #2040a0">String</span> <span style="color: #2040a0">passwordSalt</span> <span style="color: #4444FF">=</span> <span style="color: #2040a0">CustomersDB</span>.<span style="color: #2040a0">CreateSalt</span><span style="color: #4444FF">(</span><span style="color: #FF0000">5</span><span style="color: #4444FF">)</span><span style="color: #4444FF">;</span>
			<span style="color: #2040a0">String</span> <span style="color: #2040a0">passwordHash</span> <span style="color: #4444FF">=</span> <span style="color: #2040a0">CreatePasswordHash</span><span style="color: #4444FF">(</span><span style="color: #2040a0">password</span>, <span style="color: #2040a0">passwordSalt</span><span style="color: #4444FF">)</span><span style="color: #4444FF">;</span>

            <span style="color: #008000">// Create Instance of Connection and Command Object</span>
            <span style="color: #2040a0">SqlConnection</span> <span style="color: #2040a0">myConnection</span> <span style="color: #4444FF">=</span> <span style="color: #0000FF"><strong>new</strong></span> <span style="color: #2040a0">SqlConnection</span><span style="color: #4444FF">(</span><span style="color: #2040a0">Properties</span>.<span style="color: #2040a0">Settings</span>.<span style="color: #2040a0">Default</span>.<span style="color: #2040a0">ConnectionString</span><span style="color: #4444FF">)</span><span style="color: #4444FF">;</span>
            <span style="color: #2040a0">SqlCommand</span> <span style="color: #2040a0">myCommand</span> <span style="color: #4444FF">=</span> <span style="color: #0000FF"><strong>new</strong></span> <span style="color: #2040a0">SqlCommand</span><span style="color: #4444FF">(</span><span style="color: #444444">&quot;usp_CustomerAdd&quot;</span>, <span style="color: #2040a0">myConnection</span><span style="color: #4444FF">)</span><span style="color: #4444FF">;</span>

            <span style="color: #008000">// Mark the Command as a SPROC</span>
            <span style="color: #2040a0">myCommand</span>.<span style="color: #2040a0">CommandType</span> <span style="color: #4444FF">=</span> <span style="color: #2040a0">CommandType</span>.<span style="color: #2040a0">StoredProcedure</span><span style="color: #4444FF">;</span>

            <span style="color: #008000">// Add Parameters to SPROC</span>
            <span style="color: #2040a0">SqlParameter</span> <span style="color: #2040a0">parameterFirstName</span> <span style="color: #4444FF">=</span> <span style="color: #0000FF"><strong>new</strong></span> <span style="color: #2040a0">SqlParameter</span><span style="color: #4444FF">(</span><span style="color: #444444">&quot;@FirstName&quot;</span>, <span style="color: #2040a0">SqlDbType</span>.<span style="color: #2040a0">NVarChar</span>, <span style="color: #FF0000">50</span><span style="color: #4444FF">)</span><span style="color: #4444FF">;</span>
            <span style="color: #2040a0">parameterFirstName</span>.<span style="color: #2040a0">Value</span> <span style="color: #4444FF">=</span> <span style="color: #2040a0">firstName</span><span style="color: #4444FF">;</span>
            <span style="color: #2040a0">myCommand</span>.<span style="color: #2040a0">Parameters</span>.<span style="color: #2040a0">Add</span><span style="color: #4444FF">(</span><span style="color: #2040a0">parameterFirstName</span><span style="color: #4444FF">)</span><span style="color: #4444FF">;</span>

			<span style="color: #2040a0">SqlParameter</span> <span style="color: #2040a0">parameterLastName</span> <span style="color: #4444FF">=</span> <span style="color: #0000FF"><strong>new</strong></span> <span style="color: #2040a0">SqlParameter</span><span style="color: #4444FF">(</span><span style="color: #444444">&quot;@LastName&quot;</span>, <span style="color: #2040a0">SqlDbType</span>.<span style="color: #2040a0">NVarChar</span>, <span style="color: #FF0000">50</span><span style="color: #4444FF">)</span><span style="color: #4444FF">;</span>
			<span style="color: #2040a0">parameterLastName</span>.<span style="color: #2040a0">Value</span> <span style="color: #4444FF">=</span> <span style="color: #2040a0">lastName</span><span style="color: #4444FF">;</span>
			<span style="color: #2040a0">myCommand</span>.<span style="color: #2040a0">Parameters</span>.<span style="color: #2040a0">Add</span><span style="color: #4444FF">(</span><span style="color: #2040a0">parameterLastName</span><span style="color: #4444FF">)</span><span style="color: #4444FF">;</span>

            <span style="color: #2040a0">SqlParameter</span> <span style="color: #2040a0">parameterEmail</span> <span style="color: #4444FF">=</span> <span style="color: #0000FF"><strong>new</strong></span> <span style="color: #2040a0">SqlParameter</span><span style="color: #4444FF">(</span><span style="color: #444444">&quot;@Email&quot;</span>, <span style="color: #2040a0">SqlDbType</span>.<span style="color: #2040a0">NVarChar</span>, <span style="color: #FF0000">50</span><span style="color: #4444FF">)</span><span style="color: #4444FF">;</span>
            <span style="color: #2040a0">parameterEmail</span>.<span style="color: #2040a0">Value</span> <span style="color: #4444FF">=</span> <span style="color: #2040a0">email</span><span style="color: #4444FF">;</span>
            <span style="color: #2040a0">myCommand</span>.<span style="color: #2040a0">Parameters</span>.<span style="color: #2040a0">Add</span><span style="color: #4444FF">(</span><span style="color: #2040a0">parameterEmail</span><span style="color: #4444FF">)</span><span style="color: #4444FF">;</span>

            <span style="color: #2040a0">SqlParameter</span> <span style="color: #2040a0">parameterPasswordHash</span> <span style="color: #4444FF">=</span> <span style="color: #0000FF"><strong>new</strong></span> <span style="color: #2040a0">SqlParameter</span><span style="color: #4444FF">(</span><span style="color: #444444">&quot;@PasswordHash&quot;</span>, <span style="color: #2040a0">SqlDbType</span>.<span style="color: #2040a0">VarChar</span>, <span style="color: #FF0000">40</span><span style="color: #4444FF">)</span><span style="color: #4444FF">;</span>
            <span style="color: #2040a0">parameterPasswordHash</span>.<span style="color: #2040a0">Value</span> <span style="color: #4444FF">=</span> <span style="color: #2040a0">passwordHash</span><span style="color: #4444FF">;</span>
            <span style="color: #2040a0">myCommand</span>.<span style="color: #2040a0">Parameters</span>.<span style="color: #2040a0">Add</span><span style="color: #4444FF">(</span><span style="color: #2040a0">parameterPasswordHash</span><span style="color: #4444FF">)</span><span style="color: #4444FF">;</span>

			<span style="color: #2040a0">SqlParameter</span> <span style="color: #2040a0">parameterPasswordSalt</span> <span style="color: #4444FF">=</span> <span style="color: #0000FF"><strong>new</strong></span> <span style="color: #2040a0">SqlParameter</span><span style="color: #4444FF">(</span><span style="color: #444444">&quot;@PasswordSalt&quot;</span>, <span style="color: #2040a0">SqlDbType</span>.<span style="color: #2040a0">VarChar</span>, <span style="color: #FF0000">10</span><span style="color: #4444FF">)</span><span style="color: #4444FF">;</span>
			<span style="color: #2040a0">parameterPasswordSalt</span>.<span style="color: #2040a0">Value</span> <span style="color: #4444FF">=</span> <span style="color: #2040a0">passwordSalt</span><span style="color: #4444FF">;</span>
			<span style="color: #2040a0">myCommand</span>.<span style="color: #2040a0">Parameters</span>.<span style="color: #2040a0">Add</span><span style="color: #4444FF">(</span><span style="color: #2040a0">parameterPasswordSalt</span><span style="color: #4444FF">)</span><span style="color: #4444FF">;</span>

            <span style="color: #2040a0">SqlParameter</span> <span style="color: #2040a0">parameterCustomerID</span> <span style="color: #4444FF">=</span> <span style="color: #0000FF"><strong>new</strong></span> <span style="color: #2040a0">SqlParameter</span><span style="color: #4444FF">(</span><span style="color: #444444">&quot;@CustomerID&quot;</span>, <span style="color: #2040a0">SqlDbType</span>.<span style="color: #2040a0">Int</span>, <span style="color: #FF0000">4</span><span style="color: #4444FF">)</span><span style="color: #4444FF">;</span>
            <span style="color: #2040a0">parameterCustomerID</span>.<span style="color: #2040a0">Direction</span> <span style="color: #4444FF">=</span> <span style="color: #2040a0">ParameterDirection</span>.<span style="color: #2040a0">Output</span><span style="color: #4444FF">;</span>
            <span style="color: #2040a0">myCommand</span>.<span style="color: #2040a0">Parameters</span>.<span style="color: #2040a0">Add</span><span style="color: #4444FF">(</span><span style="color: #2040a0">parameterCustomerID</span><span style="color: #4444FF">)</span><span style="color: #4444FF">;</span>

			<span style="color: #2040a0">try</span> 
			<span style="color: #4444FF"><strong>{</strong></span>
				<span style="color: #2040a0">myConnection</span>.<span style="color: #2040a0">Open</span><span style="color: #4444FF">(</span><span style="color: #4444FF">)</span><span style="color: #4444FF">;</span>
				<span style="color: #2040a0">myCommand</span>.<span style="color: #2040a0">ExecuteNonQuery</span><span style="color: #4444FF">(</span><span style="color: #4444FF">)</span><span style="color: #4444FF">;</span>

				<span style="color: #008000">// Calculate the CustomerID using Output Param from SPROC</span>
				<span style="color: #0000FF"><strong>int</strong></span> <span style="color: #2040a0">customerId</span> <span style="color: #4444FF">=</span> <span style="color: #4444FF">(</span><span style="color: #0000FF"><strong>int</strong></span><span style="color: #4444FF">)</span><span style="color: #2040a0">parameterCustomerID</span>.<span style="color: #2040a0">Value</span><span style="color: #4444FF">;</span>

				<span style="color: #0000FF"><strong>return</strong></span> <span style="color: #2040a0">customerId</span>.<span style="color: #2040a0">ToString</span><span style="color: #4444FF">(</span><span style="color: #2040a0">CultureInfo</span>.<span style="color: #2040a0">InvariantCulture</span><span style="color: #4444FF">)</span><span style="color: #4444FF">;</span>
			<span style="color: #4444FF"><strong>}</strong></span>
			<span style="color: #2040a0">finally</span>
			<span style="color: #4444FF"><strong>{</strong></span>
				<span style="color: #0000FF"><strong>if</strong></span> <span style="color: #4444FF">(</span><span style="color: #2040a0">myConnection</span>.<span style="color: #2040a0">State</span> <span style="color: #4444FF">!</span><span style="color: #4444FF">=</span> <span style="color: #2040a0">ConnectionState</span>.<span style="color: #2040a0">Closed</span><span style="color: #4444FF">)</span>
					<span style="color: #2040a0">myConnection</span>.<span style="color: #2040a0">Close</span><span style="color: #4444FF">(</span><span style="color: #4444FF">)</span><span style="color: #4444FF">;</span>
			<span style="color: #4444FF"><strong>}</strong></span>
            
        <span style="color: #4444FF"><strong>}</strong></span>

		<span style="color: #0000FF"><strong>public</strong></span> <span style="color: #0000FF"><strong>void</strong></span> <span style="color: #2040a0">AddCustomerSurvey</span><span style="color: #4444FF">(</span><span style="color: #0000FF"><strong>int</strong></span> <span style="color: #2040a0">customerID</span>, <span style="color: #2040a0">string</span> <span style="color: #2040a0">survey</span><span style="color: #4444FF">)</span>
		<span style="color: #4444FF"><strong>{</strong></span>
			<span style="color: #008000">// Create Instance of Connection and Command Object</span>
			<span style="color: #0000FF"><strong>using</strong></span> <span style="color: #4444FF">(</span><span style="color: #2040a0">SqlConnection</span> <span style="color: #2040a0">myConnection</span> <span style="color: #4444FF">=</span>
            <span style="color: #0000FF"><strong>new</strong></span> <span style="color: #2040a0">SqlConnection</span><span style="color: #4444FF">(</span><span style="color: #2040a0">Properties</span>.<span style="color: #2040a0">Settings</span>.<span style="color: #2040a0">Default</span>.<span style="color: #2040a0">ConnectionString</span><span style="color: #4444FF">)</span><span style="color: #4444FF">)</span>
			<span style="color: #4444FF"><strong>{</strong></span>
				<span style="color: #2040a0">SqlCommand</span> <span style="color: #2040a0">myCommand</span> <span style="color: #4444FF">=</span> <span style="color: #0000FF"><strong>new</strong></span> <span style="color: #2040a0">SqlCommand</span><span style="color: #4444FF">(</span><span style="color: #444444">&quot;usp_CustomerAddSurvey&quot;</span>,
													  <span style="color: #2040a0">myConnection</span><span style="color: #4444FF">)</span><span style="color: #4444FF">;</span>

				<span style="color: #008000">// Mark the Command as a SPROC</span>
				<span style="color: #2040a0">myCommand</span>.<span style="color: #2040a0">CommandType</span> <span style="color: #4444FF">=</span> <span style="color: #2040a0">CommandType</span>.<span style="color: #2040a0">StoredProcedure</span><span style="color: #4444FF">;</span>

				<span style="color: #008000">// Add Parameters to SPROC</span>
				<span style="color: #2040a0">SqlParameter</span> <span style="color: #2040a0">parameterCustomerID</span> <span style="color: #4444FF">=</span> <span style="color: #0000FF"><strong>new</strong></span> <span style="color: #2040a0">SqlParameter</span><span style="color: #4444FF">(</span>
					<span style="color: #444444">&quot;@CustomerID&quot;</span>, <span style="color: #2040a0">SqlDbType</span>.<span style="color: #2040a0">Int</span><span style="color: #4444FF">)</span><span style="color: #4444FF">;</span>

				<span style="color: #2040a0">parameterCustomerID</span>.<span style="color: #2040a0">Value</span> <span style="color: #4444FF">=</span> <span style="color: #2040a0">customerID</span><span style="color: #4444FF">;</span>
				<span style="color: #2040a0">myCommand</span>.<span style="color: #2040a0">Parameters</span>.<span style="color: #2040a0">Add</span><span style="color: #4444FF">(</span><span style="color: #2040a0">parameterCustomerID</span><span style="color: #4444FF">)</span><span style="color: #4444FF">;</span>

				<span style="color: #2040a0">SqlParameter</span> <span style="color: #2040a0">parameterSurvey</span> <span style="color: #4444FF">=</span> <span style="color: #0000FF"><strong>new</strong></span> <span style="color: #2040a0">SqlParameter</span><span style="color: #4444FF">(</span>
					<span style="color: #444444">&quot;@CustomerSurvey&quot;</span>, <span style="color: #2040a0">SqlDbType</span>.<span style="color: #2040a0">NVarChar</span>, <span style="color: #FF0000">2048</span><span style="color: #4444FF">)</span><span style="color: #4444FF">;</span>

				<span style="color: #2040a0">parameterSurvey</span>.<span style="color: #2040a0">Value</span> <span style="color: #4444FF">=</span> <span style="color: #2040a0">survey</span><span style="color: #4444FF">;</span>
				<span style="color: #2040a0">myCommand</span>.<span style="color: #2040a0">Parameters</span>.<span style="color: #2040a0">Add</span><span style="color: #4444FF">(</span><span style="color: #2040a0">parameterSurvey</span><span style="color: #4444FF">)</span><span style="color: #4444FF">;</span>

				<span style="color: #2040a0">myConnection</span>.<span style="color: #2040a0">Open</span><span style="color: #4444FF">(</span><span style="color: #4444FF">)</span><span style="color: #4444FF">;</span>
				<span style="color: #2040a0">myCommand</span>.<span style="color: #2040a0">ExecuteNonQuery</span><span style="color: #4444FF">(</span><span style="color: #4444FF">)</span><span style="color: #4444FF">;</span>
			<span style="color: #4444FF"><strong>}</strong></span>

		<span style="color: #4444FF"><strong>}</strong></span>

		<span style="color: #0000FF"><strong>public</strong></span> <span style="color: #0000FF"><strong>void</strong></span> <span style="color: #2040a0">UpdateCustomer</span><span style="color: #4444FF">(</span><span style="color: #0000FF"><strong>int</strong></span> <span style="color: #2040a0">customerID</span>, <span style="color: #2040a0">string</span> <span style="color: #2040a0">firstName</span>, <span style="color: #2040a0">string</span> <span style="color: #2040a0">lastName</span>,
								  <span style="color: #2040a0">string</span> <span style="color: #2040a0">email</span>, <span style="color: #2040a0">string</span> <span style="color: #2040a0">password</span>, <span style="color: #2040a0">string</span> <span style="color: #2040a0">passwordSalt</span>, <span style="color: #0000FF"><strong>int</strong></span> <span style="color: #2040a0">emailPromotion</span><span style="color: #4444FF">)</span>
		<span style="color: #4444FF"><strong>{</strong></span>
			<span style="color: #2040a0">String</span> <span style="color: #2040a0">passwordHash</span> <span style="color: #4444FF">=</span> <span style="color: #4444FF">(</span><span style="color: #2040a0">password</span>.<span style="color: #2040a0">Equals</span><span style="color: #4444FF">(</span><span style="color: #2040a0">String</span>.<span style="color: #2040a0">Empty</span><span style="color: #4444FF">)</span><span style="color: #4444FF">)</span> ? <span style="color: #444444">&quot;&quot;</span> 
				   <span style="color: #4444FF">:</span> <span style="color: #2040a0">CreatePasswordHash</span><span style="color: #4444FF">(</span><span style="color: #2040a0">password</span>, <span style="color: #2040a0">passwordSalt</span><span style="color: #4444FF">)</span><span style="color: #4444FF">;</span>

			<span style="color: #008000">// Create Instance of Connection and Command Object</span>
			<span style="color: #2040a0">SqlConnection</span> <span style="color: #2040a0">myConnection</span> <span style="color: #4444FF">=</span> <span style="color: #0000FF"><strong>new</strong></span> <span style="color: #2040a0">SqlConnection</span><span style="color: #4444FF">(</span>
                <span style="color: #2040a0">Properties</span>.<span style="color: #2040a0">Settings</span>.<span style="color: #2040a0">Default</span>.<span style="color: #2040a0">ConnectionString</span><span style="color: #4444FF">)</span><span style="color: #4444FF">;</span>
			<span style="color: #2040a0">SqlCommand</span> <span style="color: #2040a0">myCommand</span> <span style="color: #4444FF">=</span> <span style="color: #0000FF"><strong>new</strong></span> <span style="color: #2040a0">SqlCommand</span><span style="color: #4444FF">(</span><span style="color: #444444">&quot;usp_CustomerUpdate&quot;</span>,
												  <span style="color: #2040a0">myConnection</span><span style="color: #4444FF">)</span><span style="color: #4444FF">;</span>

			<span style="color: #008000">// Mark the Command as a SPROC</span>
			<span style="color: #2040a0">myCommand</span>.<span style="color: #2040a0">CommandType</span> <span style="color: #4444FF">=</span> <span style="color: #2040a0">CommandType</span>.<span style="color: #2040a0">StoredProcedure</span><span style="color: #4444FF">;</span>

			<span style="color: #008000">// Add Parameters to SPROC</span>
			<span style="color: #2040a0">SqlParameter</span> <span style="color: #2040a0">parameterCustomerID</span> <span style="color: #4444FF">=</span> <span style="color: #0000FF"><strong>new</strong></span> <span style="color: #2040a0">SqlParameter</span><span style="color: #4444FF">(</span><span style="color: #444444">&quot;@CustomerID&quot;</span>,
																<span style="color: #2040a0">SqlDbType</span>.<span style="color: #2040a0">Int</span>,
																<span style="color: #FF0000">4</span><span style="color: #4444FF">)</span><span style="color: #4444FF">;</span>
			<span style="color: #2040a0">parameterCustomerID</span>.<span style="color: #2040a0">Value</span> <span style="color: #4444FF">=</span> <span style="color: #2040a0">customerID</span><span style="color: #4444FF">;</span>
			<span style="color: #2040a0">myCommand</span>.<span style="color: #2040a0">Parameters</span>.<span style="color: #2040a0">Add</span><span style="color: #4444FF">(</span><span style="color: #2040a0">parameterCustomerID</span><span style="color: #4444FF">)</span><span style="color: #4444FF">;</span>

			<span style="color: #2040a0">SqlParameter</span> <span style="color: #2040a0">parameterFirstName</span> <span style="color: #4444FF">=</span> <span style="color: #0000FF"><strong>new</strong></span> <span style="color: #2040a0">SqlParameter</span><span style="color: #4444FF">(</span><span style="color: #444444">&quot;@FirstName&quot;</span>,
															   <span style="color: #2040a0">SqlDbType</span>.
															   <span style="color: #2040a0">NVarChar</span>, <span style="color: #FF0000">50</span><span style="color: #4444FF">)</span><span style="color: #4444FF">;</span>

			<span style="color: #2040a0">parameterFirstName</span>.<span style="color: #2040a0">Value</span> <span style="color: #4444FF">=</span> <span style="color: #2040a0">firstName</span><span style="color: #4444FF">;</span>
			<span style="color: #2040a0">myCommand</span>.<span style="color: #2040a0">Parameters</span>.<span style="color: #2040a0">Add</span><span style="color: #4444FF">(</span><span style="color: #2040a0">parameterFirstName</span><span style="color: #4444FF">)</span><span style="color: #4444FF">;</span>

			<span style="color: #2040a0">SqlParameter</span> <span style="color: #2040a0">parameterLastName</span> <span style="color: #4444FF">=</span> <span style="color: #0000FF"><strong>new</strong></span> <span style="color: #2040a0">SqlParameter</span><span style="color: #4444FF">(</span><span style="color: #444444">&quot;@LastName&quot;</span>,
															  <span style="color: #2040a0">SqlDbType</span>.
															  <span style="color: #2040a0">NVarChar</span>, <span style="color: #FF0000">50</span><span style="color: #4444FF">)</span><span style="color: #4444FF">;</span>

			<span style="color: #2040a0">parameterLastName</span>.<span style="color: #2040a0">Value</span> <span style="color: #4444FF">=</span> <span style="color: #2040a0">lastName</span><span style="color: #4444FF">;</span>
			<span style="color: #2040a0">myCommand</span>.<span style="color: #2040a0">Parameters</span>.<span style="color: #2040a0">Add</span><span style="color: #4444FF">(</span><span style="color: #2040a0">parameterLastName</span><span style="color: #4444FF">)</span><span style="color: #4444FF">;</span>

			<span style="color: #2040a0">SqlParameter</span> <span style="color: #2040a0">parameterEmail</span> <span style="color: #4444FF">=</span> <span style="color: #0000FF"><strong>new</strong></span> <span style="color: #2040a0">SqlParameter</span><span style="color: #4444FF">(</span><span style="color: #444444">&quot;@Email&quot;</span>,
														   <span style="color: #2040a0">SqlDbType</span>.<span style="color: #2040a0">NVarChar</span>,
														   <span style="color: #FF0000">50</span><span style="color: #4444FF">)</span><span style="color: #4444FF">;</span>

			<span style="color: #2040a0">parameterEmail</span>.<span style="color: #2040a0">Value</span> <span style="color: #4444FF">=</span> <span style="color: #2040a0">email</span><span style="color: #4444FF">;</span>
			<span style="color: #2040a0">myCommand</span>.<span style="color: #2040a0">Parameters</span>.<span style="color: #2040a0">Add</span><span style="color: #4444FF">(</span><span style="color: #2040a0">parameterEmail</span><span style="color: #4444FF">)</span><span style="color: #4444FF">;</span>

			<span style="color: #2040a0">SqlParameter</span> <span style="color: #2040a0">parameterPasswordHash</span> <span style="color: #4444FF">=</span> <span style="color: #0000FF"><strong>new</strong></span> <span style="color: #2040a0">SqlParameter</span><span style="color: #4444FF">(</span>
				<span style="color: #444444">&quot;@PasswordHash&quot;</span>, <span style="color: #2040a0">SqlDbType</span>.<span style="color: #2040a0">VarChar</span>, <span style="color: #FF0000">40</span><span style="color: #4444FF">)</span><span style="color: #4444FF">;</span>
			<span style="color: #2040a0">parameterPasswordHash</span>.<span style="color: #2040a0">Value</span> <span style="color: #4444FF">=</span> <span style="color: #2040a0">passwordHash</span><span style="color: #4444FF">;</span>
			<span style="color: #2040a0">myCommand</span>.<span style="color: #2040a0">Parameters</span>.<span style="color: #2040a0">Add</span><span style="color: #4444FF">(</span><span style="color: #2040a0">parameterPasswordHash</span><span style="color: #4444FF">)</span><span style="color: #4444FF">;</span>

			<span style="color: #2040a0">SqlParameter</span> <span style="color: #2040a0">parameterEmailPromotion</span> <span style="color: #4444FF">=</span> <span style="color: #0000FF"><strong>new</strong></span> <span style="color: #2040a0">SqlParameter</span><span style="color: #4444FF">(</span>
				<span style="color: #444444">&quot;@EmailPromotion&quot;</span>, <span style="color: #2040a0">SqlDbType</span>.<span style="color: #2040a0">Int</span><span style="color: #4444FF">)</span><span style="color: #4444FF">;</span>
			<span style="color: #2040a0">parameterEmailPromotion</span>.<span style="color: #2040a0">Value</span> <span style="color: #4444FF">=</span> <span style="color: #2040a0">emailPromotion</span><span style="color: #4444FF">;</span>
			<span style="color: #2040a0">myCommand</span>.<span style="color: #2040a0">Parameters</span>.<span style="color: #2040a0">Add</span><span style="color: #4444FF">(</span><span style="color: #2040a0">parameterEmailPromotion</span><span style="color: #4444FF">)</span><span style="color: #4444FF">;</span>

			<span style="color: #2040a0">try</span>
			<span style="color: #4444FF"><strong>{</strong></span>
				<span style="color: #2040a0">myConnection</span>.<span style="color: #2040a0">Open</span><span style="color: #4444FF">(</span><span style="color: #4444FF">)</span><span style="color: #4444FF">;</span>
				<span style="color: #2040a0">myCommand</span>.<span style="color: #2040a0">ExecuteNonQuery</span><span style="color: #4444FF">(</span><span style="color: #4444FF">)</span><span style="color: #4444FF">;</span>

			<span style="color: #4444FF"><strong>}</strong></span>
			<span style="color: #2040a0">finally</span>
			<span style="color: #4444FF"><strong>{</strong></span>
				<span style="color: #0000FF"><strong>if</strong></span> <span style="color: #4444FF">(</span><span style="color: #2040a0">myConnection</span>.<span style="color: #2040a0">State</span> <span style="color: #4444FF">!</span><span style="color: #4444FF">=</span> <span style="color: #2040a0">ConnectionState</span>.<span style="color: #2040a0">Closed</span><span style="color: #4444FF">)</span>
					<span style="color: #2040a0">myConnection</span>.<span style="color: #2040a0">Close</span><span style="color: #4444FF">(</span><span style="color: #4444FF">)</span><span style="color: #4444FF">;</span>
			<span style="color: #4444FF"><strong>}</strong></span>
		<span style="color: #4444FF"><strong>}</strong></span>

		<span style="color: #0000FF"><strong>private</strong></span> <span style="color: #0000FF"><strong>int</strong></span> <span style="color: #2040a0">GetCustomerID</span><span style="color: #4444FF">(</span><span style="color: #2040a0">string</span> <span style="color: #2040a0">email</span><span style="color: #4444FF">)</span>
		<span style="color: #4444FF"><strong>{</strong></span>
			<span style="color: #008000">// Create Instance of Connection and Command Object</span>
			<span style="color: #2040a0">SqlConnection</span> <span style="color: #2040a0">myConnection</span> <span style="color: #4444FF">=</span> <span style="color: #0000FF"><strong>new</strong></span> <span style="color: #2040a0">SqlConnection</span><span style="color: #4444FF">(</span><span style="color: #2040a0">Properties</span>.<span style="color: #2040a0">Settings</span>.<span style="color: #2040a0">Default</span>.<span style="color: #2040a0">ConnectionString</span><span style="color: #4444FF">)</span><span style="color: #4444FF">;</span>
			<span style="color: #2040a0">SqlCommand</span> <span style="color: #2040a0">myCommand</span> <span style="color: #4444FF">=</span> <span style="color: #0000FF"><strong>new</strong></span> <span style="color: #2040a0">SqlCommand</span><span style="color: #4444FF">(</span><span style="color: #444444">&quot;usp_CustomerLogin&quot;</span>, <span style="color: #2040a0">myConnection</span><span style="color: #4444FF">)</span><span style="color: #4444FF">;</span>

			<span style="color: #008000">// Mark the Command as a SPROC</span>
			<span style="color: #2040a0">myCommand</span>.<span style="color: #2040a0">CommandType</span> <span style="color: #4444FF">=</span> <span style="color: #2040a0">CommandType</span>.<span style="color: #2040a0">StoredProcedure</span><span style="color: #4444FF">;</span>

			<span style="color: #008000">// Add Parameters to SPROC</span>
			<span style="color: #2040a0">SqlParameter</span> <span style="color: #2040a0">parameterEmail</span> <span style="color: #4444FF">=</span> <span style="color: #0000FF"><strong>new</strong></span> <span style="color: #2040a0">SqlParameter</span><span style="color: #4444FF">(</span><span style="color: #444444">&quot;@Email&quot;</span>, <span style="color: #2040a0">SqlDbType</span>.<span style="color: #2040a0">NVarChar</span>, <span style="color: #FF0000">50</span><span style="color: #4444FF">)</span><span style="color: #4444FF">;</span>
			<span style="color: #2040a0">parameterEmail</span>.<span style="color: #2040a0">Value</span> <span style="color: #4444FF">=</span> <span style="color: #2040a0">email</span><span style="color: #4444FF">;</span>
			<span style="color: #2040a0">myCommand</span>.<span style="color: #2040a0">Parameters</span>.<span style="color: #2040a0">Add</span><span style="color: #4444FF">(</span><span style="color: #2040a0">parameterEmail</span><span style="color: #4444FF">)</span><span style="color: #4444FF">;</span>

			<span style="color: #2040a0">SqlParameter</span> <span style="color: #2040a0">parameterCustomerID</span> <span style="color: #4444FF">=</span> <span style="color: #0000FF"><strong>new</strong></span> <span style="color: #2040a0">SqlParameter</span><span style="color: #4444FF">(</span><span style="color: #444444">&quot;@CustomerID&quot;</span>, <span style="color: #2040a0">SqlDbType</span>.<span style="color: #2040a0">Int</span>, <span style="color: #FF0000">4</span><span style="color: #4444FF">)</span><span style="color: #4444FF">;</span>
			<span style="color: #2040a0">parameterCustomerID</span>.<span style="color: #2040a0">Direction</span> <span style="color: #4444FF">=</span> <span style="color: #2040a0">ParameterDirection</span>.<span style="color: #2040a0">Output</span><span style="color: #4444FF">;</span>
			<span style="color: #2040a0">myCommand</span>.<span style="color: #2040a0">Parameters</span>.<span style="color: #2040a0">Add</span><span style="color: #4444FF">(</span><span style="color: #2040a0">parameterCustomerID</span><span style="color: #4444FF">)</span><span style="color: #4444FF">;</span>

			<span style="color: #2040a0">try</span>
			<span style="color: #4444FF"><strong>{</strong></span>
				<span style="color: #008000">// Open the connection and execute the Command</span>
				<span style="color: #2040a0">myConnection</span>.<span style="color: #2040a0">Open</span><span style="color: #4444FF">(</span><span style="color: #4444FF">)</span><span style="color: #4444FF">;</span>
				<span style="color: #2040a0">myCommand</span>.<span style="color: #2040a0">ExecuteNonQuery</span><span style="color: #4444FF">(</span><span style="color: #4444FF">)</span><span style="color: #4444FF">;</span>
				
				<span style="color: #0000FF"><strong>return</strong></span> <span style="color: #4444FF">(</span><span style="color: #0000FF"><strong>int</strong></span><span style="color: #4444FF">)</span><span style="color: #4444FF">(</span><span style="color: #2040a0">parameterCustomerID</span>.<span style="color: #2040a0">Value</span><span style="color: #4444FF">)</span><span style="color: #4444FF">;</span>
			<span style="color: #4444FF"><strong>}</strong></span>
			<span style="color: #2040a0">finally</span>
			<span style="color: #4444FF"><strong>{</strong></span>
				<span style="color: #0000FF"><strong>if</strong></span> <span style="color: #4444FF">(</span><span style="color: #2040a0">myConnection</span>.<span style="color: #2040a0">State</span> <span style="color: #4444FF">!</span><span style="color: #4444FF">=</span> <span style="color: #2040a0">ConnectionState</span>.<span style="color: #2040a0">Closed</span><span style="color: #4444FF">)</span>
				<span style="color: #4444FF"><strong>{</strong></span>
					<span style="color: #2040a0">myConnection</span>.<span style="color: #2040a0">Close</span><span style="color: #4444FF">(</span><span style="color: #4444FF">)</span><span style="color: #4444FF">;</span>
				<span style="color: #4444FF"><strong>}</strong></span>
			<span style="color: #4444FF"><strong>}</strong></span>
		<span style="color: #4444FF"><strong>}</strong></span>

        <span style="color: #008000">//*******************************************************</span>
        <span style="color: #008000">//</span>
        <span style="color: #008000">// CustomersDB.Login() Method &lt;a name=&quot;Login&quot;&gt;&lt;/a&gt;</span>
        <span style="color: #008000">//</span>
        <span style="color: #008000">// The Login method validates a email/password pair</span>
        <span style="color: #008000">// against credentials stored in the database.</span>
        <span style="color: #008000">// If the email/password pair is valid, the method returns</span>
        <span style="color: #008000">// the &quot;CustomerId&quot; number of the customer.  Otherwise</span>
        <span style="color: #008000">// it will throw an exception.</span>
        <span style="color: #008000">//</span>
        <span style="color: #008000">// Other relevant sources:</span>
        <span style="color: #008000">//     + &lt;a href=&quot;usp_CustomerLogin.htm&quot; style=&quot;color:green&quot;&gt;usp_CustomerLogin Stored Procedure&lt;/a&gt;</span>
        <span style="color: #008000">//</span>
        <span style="color: #008000">//*******************************************************</span>

        <span style="color: #0000FF"><strong>public</strong></span> <span style="color: #2040a0">CustomerDetails</span> <span style="color: #2040a0">Login</span><span style="color: #4444FF">(</span><span style="color: #2040a0">string</span> <span style="color: #2040a0">email</span>, <span style="color: #2040a0">string</span> <span style="color: #2040a0">password</span><span style="color: #4444FF">)</span> 
        <span style="color: #4444FF"><strong>{</strong></span>
            <span style="color: #0000FF"><strong>int</strong></span> <span style="color: #2040a0">customerId</span> <span style="color: #4444FF">=</span> <span style="color: #2040a0">GetCustomerID</span><span style="color: #4444FF">(</span><span style="color: #2040a0">email</span><span style="color: #4444FF">)</span><span style="color: #4444FF">;</span>

            <span style="color: #0000FF"><strong>if</strong></span> <span style="color: #4444FF">(</span><span style="color: #2040a0">customerId</span> <span style="color: #4444FF">=</span><span style="color: #4444FF">=</span> <span style="color: #FF0000">0</span><span style="color: #4444FF">)</span> <span style="color: #4444FF"><strong>{</strong></span>
                <span style="color: #0000FF"><strong>return</strong></span> <span style="color: #2040a0">null</span><span style="color: #4444FF">;</span>
            <span style="color: #4444FF"><strong>}</strong></span>
            <span style="color: #0000FF"><strong>else</strong></span> <span style="color: #4444FF"><strong>{</strong></span>
				<span style="color: #008000">//Lookup information (including password hash and password salt) about the specified user</span>
				<span style="color: #2040a0">CustomerDetails</span> <span style="color: #2040a0">result</span> <span style="color: #4444FF">=</span> <span style="color: #2040a0">GetCustomerDetails</span><span style="color: #4444FF">(</span><span style="color: #2040a0">customerId</span>.<span style="color: #2040a0">ToString</span><span style="color: #4444FF">(</span><span style="color: #2040a0">CultureInfo</span>.<span style="color: #2040a0">InvariantCulture</span><span style="color: #4444FF">)</span><span style="color: #4444FF">)</span><span style="color: #4444FF">;</span>
				<span style="color: #008000">// Now take the salt and the password entered by the user</span>
				<span style="color: #008000">// and concatenate them together.</span>
				<span style="color: #2040a0">string</span> <span style="color: #2040a0">passwordAndSalt</span> <span style="color: #4444FF">=</span> <span style="color: #2040a0">String</span>.<span style="color: #2040a0">Concat</span><span style="color: #4444FF">(</span><span style="color: #2040a0">password</span>, <span style="color: #2040a0">result</span>.<span style="color: #2040a0">PasswordSalt</span><span style="color: #4444FF">)</span><span style="color: #4444FF">;</span>
				<span style="color: #008000">// Now hash them</span>
				<span style="color: #2040a0">string</span> <span style="color: #2040a0">hashedPasswordAndSalt</span> <span style="color: #4444FF">=</span>
					<span style="color: #2040a0">FormsAuthentication</span>.<span style="color: #2040a0">HashPasswordForStoringInConfigFile</span><span style="color: #4444FF">(</span>
					<span style="color: #2040a0">passwordAndSalt</span>, <span style="color: #444444">&quot;SHA1&quot;</span><span style="color: #4444FF">)</span><span style="color: #4444FF">;</span>
				<span style="color: #008000">// Now verify them.</span>
				<span style="color: #0000FF"><strong>if</strong></span> <span style="color: #4444FF">(</span><span style="color: #2040a0">hashedPasswordAndSalt</span>.<span style="color: #2040a0">Equals</span><span style="color: #4444FF">(</span><span style="color: #2040a0">result</span>.<span style="color: #2040a0">PasswordHash</span><span style="color: #4444FF">)</span><span style="color: #4444FF">)</span>
					<span style="color: #0000FF"><strong>return</strong></span> <span style="color: #2040a0">result</span><span style="color: #4444FF">;</span>
				<span style="color: #0000FF"><strong>else</strong></span>
					<span style="color: #0000FF"><strong>return</strong></span> <span style="color: #2040a0">null</span><span style="color: #4444FF">;</span>
            <span style="color: #4444FF"><strong>}</strong></span>
        <span style="color: #4444FF"><strong>}</strong></span>

		<span style="color: #008000">//*******************************************************</span>
		<span style="color: #008000">//</span>
		<span style="color: #008000">// CustomersDB.GetAllStateProvince() Method &lt;a name=&quot;GetAllStateProvince&quot;&gt;&lt;/a&gt;</span>
		<span style="color: #008000">//</span>
		<span style="color: #008000">// The GetAllStateProvince method returns </span>
		<span style="color: #008000">// a DataTable containing a list of all</span>
		<span style="color: #008000">// State/Provicences registered in the database. </span>
		<span style="color: #008000">//</span>
		<span style="color: #008000">// Other relevant sources:</span>
		<span style="color: #008000">//     + &lt;a href=&quot;usp_CustomerAllStateProvince&quot; style=&quot;color:green&quot;&gt;CustomerAllStateProvince Stored Procedure&lt;/a&gt;</span>
		<span style="color: #008000">//</span>
		<span style="color: #008000">//*******************************************************</span>
		<span style="color: #0000FF"><strong>public</strong></span> <span style="color: #2040a0">DataTable</span> <span style="color: #2040a0">GetAllStateProvince</span><span style="color: #4444FF">(</span><span style="color: #4444FF">)</span>
		<span style="color: #4444FF"><strong>{</strong></span>
			<span style="color: #008000">// Create Instance of Connection and Command Object</span>
			<span style="color: #2040a0">SqlConnection</span> <span style="color: #2040a0">myConnection</span> <span style="color: #4444FF">=</span> <span style="color: #0000FF"><strong>new</strong></span> <span style="color: #2040a0">SqlConnection</span><span style="color: #4444FF">(</span><span style="color: #2040a0">Properties</span>.<span style="color: #2040a0">Settings</span>.<span style="color: #2040a0">Default</span>.<span style="color: #2040a0">ConnectionString</span><span style="color: #4444FF">)</span><span style="color: #4444FF">;</span>
			<span style="color: #2040a0">SqlCommand</span> <span style="color: #2040a0">myCommand</span> <span style="color: #4444FF">=</span> <span style="color: #2040a0">myConnection</span>.<span style="color: #2040a0">CreateCommand</span><span style="color: #4444FF">(</span><span style="color: #4444FF">)</span><span style="color: #4444FF">;</span>

			<span style="color: #2040a0">myCommand</span>.<span style="color: #2040a0">CommandText</span> <span style="color: #4444FF">=</span> <span style="color: #444444">&quot;usp_CustomerAllStateProvince&quot;</span><span style="color: #4444FF">;</span>

			<span style="color: #008000">// Mark the Command as a SPROC</span>
			<span style="color: #2040a0">myCommand</span>.<span style="color: #2040a0">CommandType</span> <span style="color: #4444FF">=</span> <span style="color: #2040a0">CommandType</span>.<span style="color: #2040a0">StoredProcedure</span><span style="color: #4444FF">;</span>

			<span style="color: #2040a0">DataTable</span> <span style="color: #2040a0">result</span> <span style="color: #4444FF">=</span> <span style="color: #0000FF"><strong>new</strong></span> <span style="color: #2040a0">DataTable</span><span style="color: #4444FF">(</span><span style="color: #4444FF">)</span><span style="color: #4444FF">;</span>
            <span style="color: #2040a0">result</span>.<span style="color: #2040a0">Locale</span> <span style="color: #4444FF">=</span> <span style="color: #2040a0">CultureInfo</span>.<span style="color: #2040a0">InvariantCulture</span><span style="color: #4444FF">;</span>
            <span style="color: #2040a0">SqlDataAdapter</span> <span style="color: #2040a0">sda</span> <span style="color: #4444FF">=</span> <span style="color: #0000FF"><strong>new</strong></span> <span style="color: #2040a0">SqlDataAdapter</span><span style="color: #4444FF">(</span><span style="color: #2040a0">myCommand</span><span style="color: #4444FF">)</span><span style="color: #4444FF">;</span>

			<span style="color: #2040a0">sda</span>.<span style="color: #2040a0">Fill</span><span style="color: #4444FF">(</span><span style="color: #2040a0">result</span><span style="color: #4444FF">)</span><span style="color: #4444FF">;</span>
			
			<span style="color: #0000FF"><strong>return</strong></span> <span style="color: #2040a0">result</span><span style="color: #4444FF">;</span>
		<span style="color: #4444FF"><strong>}</strong></span>

		<span style="color: #008000">//*******************************************************</span>
		<span style="color: #008000">//</span>
		<span style="color: #008000">// CustomersDB.GetCustomerDefaultAddresses() Method &lt;a name=&quot;GetCustomerDefaultAddresses&quot;&gt;&lt;/a&gt;</span>
		<span style="color: #008000">//</span>
		<span style="color: #008000">// The GetCustomerDefaultAddresses method returns </span>
		<span style="color: #008000">// a DataSet containing two tables (default billing and shipping address tables, each with </span>
		<span style="color: #008000">// one row). </span>
		<span style="color: #008000">//</span>
		<span style="color: #008000">// Other relevant sources:</span>
		<span style="color: #008000">//     + &lt;a href=&quot;usp_CustomerDefaultAddresses&quot; style=&quot;color:green&quot;&gt;usp_CustomerDefaultAddresses Stored Procedure&lt;/a&gt;</span>
		<span style="color: #008000">//</span>
		<span style="color: #008000">//*******************************************************</span>
		<span style="color: #0000FF"><strong>public</strong></span> <span style="color: #2040a0">CustomerAddresses</span> <span style="color: #2040a0">GetCustomerDefaultAddresses</span><span style="color: #4444FF">(</span><span style="color: #0000FF"><strong>int</strong></span> <span style="color: #2040a0">customerID</span><span style="color: #4444FF">)</span>
		<span style="color: #4444FF"><strong>{</strong></span>
			<span style="color: #2040a0">SqlConnection</span> <span style="color: #2040a0">myConnection</span> <span style="color: #4444FF">=</span> <span style="color: #0000FF"><strong>new</strong></span> <span style="color: #2040a0">SqlConnection</span><span style="color: #4444FF">(</span><span style="color: #2040a0">Properties</span>.<span style="color: #2040a0">Settings</span>.<span style="color: #2040a0">Default</span>.<span style="color: #2040a0">ConnectionString</span><span style="color: #4444FF">)</span><span style="color: #4444FF">;</span>
			<span style="color: #2040a0">SqlCommand</span> <span style="color: #2040a0">myCommand</span> <span style="color: #4444FF">=</span> <span style="color: #2040a0">myConnection</span>.<span style="color: #2040a0">CreateCommand</span><span style="color: #4444FF">(</span><span style="color: #4444FF">)</span><span style="color: #4444FF">;</span>

			<span style="color: #2040a0">myCommand</span>.<span style="color: #2040a0">CommandText</span> <span style="color: #4444FF">=</span> <span style="color: #444444">&quot;usp_CustomerDefaultAddresses&quot;</span><span style="color: #4444FF">;</span>
			<span style="color: #2040a0">SqlParameter</span> <span style="color: #2040a0">customerIDParameter</span> <span style="color: #4444FF">=</span> <span style="color: #0000FF"><strong>new</strong></span> <span style="color: #2040a0">SqlParameter</span><span style="color: #4444FF">(</span><span style="color: #444444">&quot;@CustomerID&quot;</span>, <span style="color: #2040a0">SqlDbType</span>.<span style="color: #2040a0">Int</span><span style="color: #4444FF">)</span><span style="color: #4444FF">;</span>
			<span style="color: #2040a0">myCommand</span>.<span style="color: #2040a0">Parameters</span>.<span style="color: #2040a0">Add</span><span style="color: #4444FF">(</span><span style="color: #2040a0">customerIDParameter</span><span style="color: #4444FF">)</span><span style="color: #4444FF">;</span>
			<span style="color: #2040a0">customerIDParameter</span>.<span style="color: #2040a0">Value</span> <span style="color: #4444FF">=</span> <span style="color: #2040a0">customerID</span><span style="color: #4444FF">;</span>

			<span style="color: #008000">// Mark the Command as a SPROC</span>
			<span style="color: #2040a0">myCommand</span>.<span style="color: #2040a0">CommandType</span> <span style="color: #4444FF">=</span> <span style="color: #2040a0">CommandType</span>.<span style="color: #2040a0">StoredProcedure</span><span style="color: #4444FF">;</span>

			<span style="color: #2040a0">DataSet</span> <span style="color: #2040a0">ds</span> <span style="color: #4444FF">=</span> <span style="color: #0000FF"><strong>new</strong></span> <span style="color: #2040a0">DataSet</span><span style="color: #4444FF">(</span><span style="color: #444444">&quot;Default Addresses&quot;</span><span style="color: #4444FF">)</span><span style="color: #4444FF">;</span>
            <span style="color: #2040a0">ds</span>.<span style="color: #2040a0">Locale</span> <span style="color: #4444FF">=</span> <span style="color: #2040a0">CultureInfo</span>.<span style="color: #2040a0">InvariantCulture</span><span style="color: #4444FF">;</span>
            <span style="color: #2040a0">SqlDataAdapter</span> <span style="color: #2040a0">sda</span> <span style="color: #4444FF">=</span> <span style="color: #0000FF"><strong>new</strong></span> <span style="color: #2040a0">SqlDataAdapter</span><span style="color: #4444FF">(</span><span style="color: #2040a0">myCommand</span><span style="color: #4444FF">)</span><span style="color: #4444FF">;</span>

			<span style="color: #2040a0">sda</span>.<span style="color: #2040a0">Fill</span><span style="color: #4444FF">(</span><span style="color: #2040a0">ds</span><span style="color: #4444FF">)</span><span style="color: #4444FF">;</span>

			<span style="color: #2040a0">CustomerAddresses</span> <span style="color: #2040a0">result</span> <span style="color: #4444FF">=</span> <span style="color: #0000FF"><strong>new</strong></span> <span style="color: #2040a0">CustomerAddresses</span><span style="color: #4444FF">(</span><span style="color: #0000FF"><strong>new</strong></span> <span style="color: #2040a0">CustomerAddress</span><span style="color: #4444FF">(</span><span style="color: #4444FF">)</span>, <span style="color: #0000FF"><strong>new</strong></span> <span style="color: #2040a0">CustomerAddress</span><span style="color: #4444FF">(</span><span style="color: #4444FF">)</span><span style="color: #4444FF">)</span><span style="color: #4444FF">;</span>
			<span style="color: #0000FF"><strong>if</strong></span> <span style="color: #4444FF">(</span><span style="color: #2040a0">ds</span>.<span style="color: #2040a0">Tables</span>.<span style="color: #2040a0">Count</span> <span style="color: #4444FF">&gt;</span> <span style="color: #FF0000">0</span><span style="color: #4444FF">)</span>
			<span style="color: #4444FF"><strong>{</strong></span>
				<span style="color: #2040a0">result</span>.<span style="color: #2040a0">BillingAddress</span>.<span style="color: #2040a0">FillAddress</span><span style="color: #4444FF">(</span><span style="color: #2040a0">ds</span>.<span style="color: #2040a0">Tables</span><span style="color: #4444FF">[</span><span style="color: #FF0000">0</span><span style="color: #4444FF">]</span><span style="color: #4444FF">)</span><span style="color: #4444FF">;</span>
				<span style="color: #0000FF"><strong>if</strong></span> <span style="color: #4444FF">(</span><span style="color: #2040a0">ds</span>.<span style="color: #2040a0">Tables</span>.<span style="color: #2040a0">Count</span> <span style="color: #4444FF">&gt;</span> <span style="color: #FF0000">1</span><span style="color: #4444FF">)</span>
					<span style="color: #2040a0">result</span>.<span style="color: #2040a0">ShippingAddress</span>.<span style="color: #2040a0">FillAddress</span><span style="color: #4444FF">(</span><span style="color: #2040a0">ds</span>.<span style="color: #2040a0">Tables</span><span style="color: #4444FF">[</span><span style="color: #FF0000">1</span><span style="color: #4444FF">]</span><span style="color: #4444FF">)</span><span style="color: #4444FF">;</span>
			<span style="color: #4444FF"><strong>}</strong></span>
					
			<span style="color: #0000FF"><strong>return</strong></span> <span style="color: #2040a0">result</span><span style="color: #4444FF">;</span>
		<span style="color: #4444FF"><strong>}</strong></span>	

		<span style="color: #0000FF"><strong>public</strong></span> <span style="color: #0000FF"><strong>int</strong></span> <span style="color: #2040a0">AccessCustomerAddress</span><span style="color: #4444FF">(</span><span style="color: #0000FF"><strong>int</strong></span> <span style="color: #2040a0">customerID</span>, <span style="color: #2040a0">String</span> <span style="color: #2040a0">addressTypeName</span>, <span style="color: #2040a0">CustomerAddress</span> <span style="color: #2040a0">customerAddress</span><span style="color: #4444FF">)</span>
		<span style="color: #4444FF"><strong>{</strong></span>
			<span style="color: #0000FF"><strong>using</strong></span> <span style="color: #4444FF">(</span><span style="color: #2040a0">SqlConnection</span> <span style="color: #2040a0">myConnection</span> <span style="color: #4444FF">=</span> <span style="color: #0000FF"><strong>new</strong></span> <span style="color: #2040a0">SqlConnection</span><span style="color: #4444FF">(</span>
				<span style="color: #2040a0">Properties</span>.<span style="color: #2040a0">Settings</span>.<span style="color: #2040a0">Default</span>.<span style="color: #2040a0">ConnectionString</span><span style="color: #4444FF">)</span><span style="color: #4444FF">)</span>
			<span style="color: #4444FF"><strong>{</strong></span>
				<span style="color: #2040a0">SqlCommand</span> <span style="color: #2040a0">myCommand</span> <span style="color: #4444FF">=</span> <span style="color: #2040a0">myConnection</span>.<span style="color: #2040a0">CreateCommand</span><span style="color: #4444FF">(</span><span style="color: #4444FF">)</span><span style="color: #4444FF">;</span>

				<span style="color: #2040a0">myCommand</span>.<span style="color: #2040a0">CommandText</span> <span style="color: #4444FF">=</span> <span style="color: #444444">&quot;usp_CustomerAccessAddress&quot;</span><span style="color: #4444FF">;</span>

				<span style="color: #008000">// Mark the Command as a SPROC</span>
				<span style="color: #2040a0">myCommand</span>.<span style="color: #2040a0">CommandType</span> <span style="color: #4444FF">=</span> <span style="color: #2040a0">CommandType</span>.<span style="color: #2040a0">StoredProcedure</span><span style="color: #4444FF">;</span>

				<span style="color: #2040a0">SqlParameter</span> <span style="color: #2040a0">parameterCustomerID</span> <span style="color: #4444FF">=</span> <span style="color: #0000FF"><strong>new</strong></span> <span style="color: #2040a0">SqlParameter</span><span style="color: #4444FF">(</span>
					<span style="color: #444444">&quot;@CustomerID&quot;</span>, <span style="color: #2040a0">SqlDbType</span>.<span style="color: #2040a0">Int</span>, <span style="color: #FF0000">4</span><span style="color: #4444FF">)</span><span style="color: #4444FF">;</span>

				<span style="color: #2040a0">myCommand</span>.<span style="color: #2040a0">Parameters</span>.<span style="color: #2040a0">Add</span><span style="color: #4444FF">(</span><span style="color: #2040a0">parameterCustomerID</span><span style="color: #4444FF">)</span><span style="color: #4444FF">;</span>
				<span style="color: #2040a0">parameterCustomerID</span>.<span style="color: #2040a0">Value</span> <span style="color: #4444FF">=</span> <span style="color: #2040a0">customerID</span><span style="color: #4444FF">;</span>

				<span style="color: #2040a0">SqlParameter</span> <span style="color: #2040a0">parameterAddressTypeName</span> <span style="color: #4444FF">=</span> <span style="color: #0000FF"><strong>new</strong></span> <span style="color: #2040a0">SqlParameter</span><span style="color: #4444FF">(</span>
					<span style="color: #444444">&quot;@AddressTypeName&quot;</span>, <span style="color: #2040a0">SqlDbType</span>.<span style="color: #2040a0">NVarChar</span>, <span style="color: #FF0000">50</span><span style="color: #4444FF">)</span><span style="color: #4444FF">;</span>

				<span style="color: #2040a0">myCommand</span>.<span style="color: #2040a0">Parameters</span>.<span style="color: #2040a0">Add</span><span style="color: #4444FF">(</span><span style="color: #2040a0">parameterAddressTypeName</span><span style="color: #4444FF">)</span><span style="color: #4444FF">;</span>
				<span style="color: #2040a0">parameterAddressTypeName</span>.<span style="color: #2040a0">Value</span> <span style="color: #4444FF">=</span> <span style="color: #2040a0">addressTypeName</span><span style="color: #4444FF">;</span>

				<span style="color: #2040a0">SqlParameter</span> <span style="color: #2040a0">parameterAddressLine1</span> <span style="color: #4444FF">=</span> <span style="color: #0000FF"><strong>new</strong></span> <span style="color: #2040a0">SqlParameter</span><span style="color: #4444FF">(</span>
					<span style="color: #444444">&quot;@AddressLine1&quot;</span>, <span style="color: #2040a0">SqlDbType</span>.<span style="color: #2040a0">NVarChar</span>, <span style="color: #FF0000">60</span><span style="color: #4444FF">)</span><span style="color: #4444FF">;</span>

				<span style="color: #2040a0">myCommand</span>.<span style="color: #2040a0">Parameters</span>.<span style="color: #2040a0">Add</span><span style="color: #4444FF">(</span><span style="color: #2040a0">parameterAddressLine1</span><span style="color: #4444FF">)</span><span style="color: #4444FF">;</span>
				<span style="color: #2040a0">parameterAddressLine1</span>.<span style="color: #2040a0">Value</span> <span style="color: #4444FF">=</span> <span style="color: #2040a0">customerAddress</span>.<span style="color: #2040a0">Line1</span><span style="color: #4444FF">;</span>

				<span style="color: #2040a0">SqlParameter</span> <span style="color: #2040a0">parameterAddressLine2</span> <span style="color: #4444FF">=</span> <span style="color: #0000FF"><strong>new</strong></span> <span style="color: #2040a0">SqlParameter</span><span style="color: #4444FF">(</span>
					<span style="color: #444444">&quot;@AddressLine2&quot;</span>, <span style="color: #2040a0">SqlDbType</span>.<span style="color: #2040a0">NVarChar</span>, <span style="color: #FF0000">60</span><span style="color: #4444FF">)</span><span style="color: #4444FF">;</span>

				<span style="color: #2040a0">myCommand</span>.<span style="color: #2040a0">Parameters</span>.<span style="color: #2040a0">Add</span><span style="color: #4444FF">(</span><span style="color: #2040a0">parameterAddressLine2</span><span style="color: #4444FF">)</span><span style="color: #4444FF">;</span>
				<span style="color: #2040a0">parameterAddressLine2</span>.<span style="color: #2040a0">Value</span> <span style="color: #4444FF">=</span> <span style="color: #2040a0">customerAddress</span>.<span style="color: #2040a0">Line2</span><span style="color: #4444FF">;</span>

				<span style="color: #2040a0">SqlParameter</span> <span style="color: #2040a0">parameterCity</span> <span style="color: #4444FF">=</span> <span style="color: #0000FF"><strong>new</strong></span> <span style="color: #2040a0">SqlParameter</span><span style="color: #4444FF">(</span><span style="color: #444444">&quot;@City&quot;</span>,
															  <span style="color: #2040a0">SqlDbType</span>.
															  <span style="color: #2040a0">NVarChar</span>, <span style="color: #FF0000">30</span><span style="color: #4444FF">)</span><span style="color: #4444FF">;</span>

				<span style="color: #2040a0">myCommand</span>.<span style="color: #2040a0">Parameters</span>.<span style="color: #2040a0">Add</span><span style="color: #4444FF">(</span><span style="color: #2040a0">parameterCity</span><span style="color: #4444FF">)</span><span style="color: #4444FF">;</span>
				<span style="color: #2040a0">parameterCity</span>.<span style="color: #2040a0">Value</span> <span style="color: #4444FF">=</span> <span style="color: #2040a0">customerAddress</span>.<span style="color: #2040a0">City</span><span style="color: #4444FF">;</span>

				<span style="color: #2040a0">SqlParameter</span> <span style="color: #2040a0">parameterStateProvinceID</span> <span style="color: #4444FF">=</span> <span style="color: #0000FF"><strong>new</strong></span> <span style="color: #2040a0">SqlParameter</span><span style="color: #4444FF">(</span>
					<span style="color: #444444">&quot;@StateProvinceID&quot;</span>, <span style="color: #2040a0">SqlDbType</span>.<span style="color: #2040a0">Int</span>, <span style="color: #FF0000">4</span><span style="color: #4444FF">)</span><span style="color: #4444FF">;</span>

				<span style="color: #2040a0">myCommand</span>.<span style="color: #2040a0">Parameters</span>.<span style="color: #2040a0">Add</span><span style="color: #4444FF">(</span><span style="color: #2040a0">parameterStateProvinceID</span><span style="color: #4444FF">)</span><span style="color: #4444FF">;</span>
				<span style="color: #2040a0">parameterStateProvinceID</span>.<span style="color: #2040a0">Value</span> <span style="color: #4444FF">=</span> <span style="color: #2040a0">customerAddress</span>.
												 <span style="color: #2040a0">StateProvinceID</span><span style="color: #4444FF">;</span>

				<span style="color: #2040a0">SqlParameter</span> <span style="color: #2040a0">parameterPostalCode</span> <span style="color: #4444FF">=</span> <span style="color: #0000FF"><strong>new</strong></span> <span style="color: #2040a0">SqlParameter</span><span style="color: #4444FF">(</span>
					<span style="color: #444444">&quot;@PostalCode&quot;</span>, <span style="color: #2040a0">SqlDbType</span>.<span style="color: #2040a0">NVarChar</span>, <span style="color: #FF0000">15</span><span style="color: #4444FF">)</span><span style="color: #4444FF">;</span>

				<span style="color: #2040a0">myCommand</span>.<span style="color: #2040a0">Parameters</span>.<span style="color: #2040a0">Add</span><span style="color: #4444FF">(</span><span style="color: #2040a0">parameterPostalCode</span><span style="color: #4444FF">)</span><span style="color: #4444FF">;</span>
				<span style="color: #2040a0">parameterPostalCode</span>.<span style="color: #2040a0">Value</span> <span style="color: #4444FF">=</span> <span style="color: #2040a0">customerAddress</span>.<span style="color: #2040a0">PostalCode</span><span style="color: #4444FF">;</span>

				<span style="color: #2040a0">SqlParameter</span> <span style="color: #2040a0">parameterAddressID</span> <span style="color: #4444FF">=</span>
							 <span style="color: #0000FF"><strong>new</strong></span> <span style="color: #2040a0">SqlParameter</span><span style="color: #4444FF">(</span><span style="color: #444444">&quot;@AddressID&quot;</span>,
																   <span style="color: #2040a0">SqlDbType</span>.
																   <span style="color: #2040a0">Int</span>, <span style="color: #FF0000">4</span><span style="color: #4444FF">)</span><span style="color: #4444FF">;</span>

				<span style="color: #2040a0">myCommand</span>.<span style="color: #2040a0">Parameters</span>.<span style="color: #2040a0">Add</span><span style="color: #4444FF">(</span><span style="color: #2040a0">parameterAddressID</span><span style="color: #4444FF">)</span><span style="color: #4444FF">;</span>
				<span style="color: #2040a0">parameterAddressID</span>.<span style="color: #2040a0">Direction</span> <span style="color: #4444FF">=</span> <span style="color: #2040a0">ParameterDirection</span>.<span style="color: #2040a0">Output</span><span style="color: #4444FF">;</span>

				<span style="color: #2040a0">myConnection</span>.<span style="color: #2040a0">Open</span><span style="color: #4444FF">(</span><span style="color: #4444FF">)</span><span style="color: #4444FF">;</span>
				<span style="color: #2040a0">myCommand</span>.<span style="color: #2040a0">ExecuteNonQuery</span><span style="color: #4444FF">(</span><span style="color: #4444FF">)</span><span style="color: #4444FF">;</span>

				<span style="color: #0000FF"><strong>return</strong></span> <span style="color: #4444FF">(</span><span style="color: #0000FF"><strong>int</strong></span><span style="color: #4444FF">)</span><span style="color: #2040a0">parameterAddressID</span>.<span style="color: #2040a0">Value</span><span style="color: #4444FF">;</span>
			<span style="color: #4444FF"><strong>}</strong></span>
		<span style="color: #4444FF"><strong>}</strong></span>
    <span style="color: #4444FF"><strong>}</strong></span>
<span style="color: #4444FF"><strong>}</strong></span>


</pre>
